- name: Creating an empty files for logs
  become: yes
  become_user: "{{ DEV_SYSTEM_USERNAME }}"
  file:
    path: "{{ item }}"
    state: touch
    mode: '777'
  with_items:
    - '{{ VHOST_ACCESS_LOG_OA }}'
    - '{{ VHOST_ERROR_LOG_OA }}'

- name: Add log files path in apache2.conf for orchard
  become: yes
  become_user: "{{ DEV_SYSTEM_USERNAME }}"
  blockinfile:
    path: "{{ ORCHARD_DIR }}/deploy/apache2.conf"
    marker: "# {mark} added custom log files"
    insertbefore: 'LogFormat '
    block: |2
          ErrorLog /var/www/html/error.logs
          CustomLog /var/www/html/access.logs combined 

- name: Replace log level debug with info in the apache2.conf in orchard
  become: yes
  become_user: "{{ DEV_SYSTEM_USERNAME }}"
  replace:
    path: "{{ ORCHARD_DIR }}/deploy/apache2.conf"
    regexp: 'LogLevel debug'
    replace: 'LogLevel info'
