- name: Create various directories for rachel
  file: path={{ item }}
        owner=root
        group=root
        mode=0755
        state=directory
  with_items:
    - /library/rachel

- name: See if rachel content is installed
  stat: path="{{ rachel_content_path }}/index.php"
  register: rachel_content

- name: Set rachel_content_found to False
  set_fact:
     rachel_content_found: False

- name: Set rachel_content_found True if found
  set_fact:
     rachel_content_found: True
  when: rachel_content.stat.exists  == true

- include_tasks: rachel_enabled.yml
  when: rachel_enabled and rachel_content_found

- name: Add 'rachel' variable values to {{ iiab_ini_file }}
  ini_file:
    path: "{{ iiab_ini_file }}"
    section: rachel
    option: "{{ item.option }}"
    value: "{{ item.value | string }}"
  with_items:
    - option: name
      value: rachel
    - option: description
      value: '"Educational resources, packaged together for download and distribution in places without internet."'
    - option: rachel_content_path
      value: "{{ rachel_content_path }}"
    - option: rachel_version
      value: "{{ rachel_version }}"
    - option: rachel_mysqldb_path
      value: "{{ rachel_mysqldb_path }}"
    - option: rachel_src_url
      value: "{{ rachel_src_url }}"
    - option: content_found
      value: "{{ rachel_content_found }}"
    - option: enabled
      value: "{{ rachel_enabled }}"
