---
- hosts: coopdevs
  remote_user: ubuntu
  become: yes

  vars:
    - sites_dir: /opt/sites
    - limesurvey_db_name: limesurvey
    - limesurvey_db_user: limesurvey

  roles:
    - common
    - http-server
    - coopdevs.org
    - role: vendor/geerlingguy.postgresql
      vars:
        - postgresql_databases:
          - name: "{{ limesurvey_db_name }}"
        - postgresql_users:
          - name: "{{ limesurvey_db_user }}"
            password: "{{ limesurvey_db_pass }}"
            db: "{{ limesurvey_db_name }}"
        - postgresql_hba_entries:
          - { type: local, database: all, user: postgres, auth_method: peer }
          - { type: host, address: "127.0.0.1/32", database: "{{ limesurvey_db_name }}", user: "{{ limesurvey_db_user }}", auth_method: md5 }
    - role: vendor/geerlingguy.php
      vars:
        - php_packages:
          - php
          - php-cli
          - php-common
          - php-mbstring
          - php-pdo-pgsql
          - php-zip
          - php-gd
          - php-apcu
          - php-fpm
          - php-xml
        - php_webserver_daemon: nginx
        - php_enable_php_fpm: true
    - role: limesurvey
      vars:
        - limesurvey_base_dir: "{{ sites_dir }}"
        - limesurvey_dir: "{{ limesurvey_base_dir }}/limesurvey"
        - limesurvey_user: limesurvey
        - limesurvey_group: limesurvey
    - role: discourse
    - role: vendor/coopdevs.certbot_nginx
      vars:
        letsencrypt_email: info@coopdevs.org
    - role: letsencrypt
      vars:
        domain_names:
          - community.coopdevs.org
          - forms.coopdevs.org
