---
# Install additional packages
- import_tasks: install.yml

# Create database for faf
- import_tasks: setup_db.yml

- import_tasks: ssl.yml

# Allow https and start httpd
- import_tasks: services.yml

- name: Create a directory /srv/faf
  file:
    path: /srv/faf
    state: directory
    owner: faf
    group: faf

- name: create folders where we place certs for fedora-messaging
  file: path=/etc/fedora-messaging/faf owner=root group=root mode=0755 state=directory

- name: install certs for fedora-messaging
  copy: src={{ item.src }}
        dest=/etc/fedora-messaging/faf/{{ item.dest }}
        owner={{ item.owner }} group=root mode={{ item.mode }}
  loop:
    - { src: "{{private}}/files/rabbitmq/{{env}}/pki/ca.crt",
        dest: "ca.crt",
        owner: faf,
        mode: 0644
      }
    - { src: "{{private}}/files/rabbitmq/{{env}}/pki/private/faf{{env_suffix}}.key",
        dest: "faf.key",
        owner: faf,
        mode: "600"
      }
    - { src: "{{private}}/files/rabbitmq/{{env}}/pki/issued/faf{{env_suffix}}.crt",
        dest: "faf.crt",
        owner: faf,
        mode: 0644
      }

# landing page
- name: install abrt-server-info-page
  package:
    name: abrt-server-info-page
    state: latest

- name: configure ADMINS
  lineinfile:
    dest: /usr/lib/python3.6/site-packages/abrt-server-info-page/config.py
    regexp: 'ADMINS ='
    line: '    ADMINS = "infrastructure@lists.fedoraproject.org"'
  notify: restart httpd

- name: configure MORE_FAF
  lineinfile:
    dest: /usr/lib/python3.6/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_FAF ='
    line: '    MORE_FAF = "https://github.com/abrt/faf/"'
  notify: restart httpd

- name: configure MORE_RS
  lineinfile:
    dest: /usr/lib/python3.6/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_RS ='
    line: '    MORE_RS = "https://github.com/abrt/retrace-server"'
  notify: restart httpd

- name: configure MORE_ABRT
  lineinfile:
    dest: /usr/lib/python3.6/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_ABRT ='
    line: '    MORE_ABRT = "https://github.com/abrt/abrt/"'
  notify: restart httpd

- name: configure MORE_GABRT
  lineinfile:
    dest: /usr/lib/python3.6/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_GABRT ='
    line: '    MORE_GABRT = "https://github.com/abrt/gnome-abrt/"'
  notify: restart httpd

- name: configure MORE_LR
  lineinfile:
    dest: /usr/lib/python3.6/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_LR ='
    line: '    MORE_LR = "https://github.com/abrt/libreport/"'
  notify: restart httpd

- name: configure MORE_SATYR
  lineinfile:
    dest: /usr/lib/python3.6/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_SATYR ='
    line: '    MORE_SATYR = "https://github.com/abrt/satyr/"'
  notify: restart httpd

- name: configure URL_FOR_FAF
  lineinfile:
    dest: /usr/lib/python3.6/site-packages/abrt-server-info-page/config.py
    regexp: 'URL_FOR_FAF ='
    line: '    URL_FOR_FAF = "https://{{ faf_server_name }}"'
  notify: restart httpd
