# Apache

- name: Enable http://box{{ dokuwiki_url }} via Apache    # http://box/dokuwiki
  command: a2ensite dokuwiki.conf
  when: apache_install and dokuwiki_enabled

- name: Disable http://box{{ dokuwiki_url }} via Apache    # http://box/dokuwiki
  command: a2dissite dokuwiki.conf
  when: apache_install and not dokuwiki_enabled

- name: Restart Apache systemd service ({{ apache_service }})
  systemd:
    name: "{{ apache_service }}"
    state: restarted
  when: apache_enabled

# NGINX

- name: "SHIM: Enable http://box{{ dokuwiki_url }} via NGINX, by installing {{ nginx_conf_dir }}/dokuwiki-nginx.conf from template"    # http://box/dokuwiki
  template:
    src: dokuwiki-nginx.conf.j2
    dest: "{{ nginx_conf_dir }}/dokuwiki-nginx.conf"
  when: nginx_install and dokuwiki_enabled

- name: "SHIM: Disable http://box{{ dokuwiki_url }} via NGINX, by removing {{ nginx_conf_dir }}/dokuwiki-nginx.conf"    # http://box/dokuwiki
  file:
    path: "{{ nginx_conf_dir }}/dokuwiki-nginx.conf"
    state: absent
  when: nginx_install and not dokuwiki_enabled

- name: Restart 'nginx' systemd service
  systemd:
    name: nginx
    state: restarted
  when: nginx_enabled


- name: Add 'dokuwiki' variable values to {{ iiab_ini_file }}
  ini_file:
    path: "{{ iiab_ini_file }}"
    section: dokuwiki
    option: "{{ item.option }}"
    value: "{{ item.value | string }}"
  with_items:
    - option: name
      value: DokuWiki
    - option: description
      value: '"DokuWiki is a simple to use and highly versatile Open Source wiki software that does not require a database."'
    - option: installed
      value: "{{ dokuwiki_install }}"
    - option: enabled
      value: "{{ dokuwiki_enabled }}"
