---

- hosts:
  - synapse

  handlers:
    - name: reboot
      reboot:

  pre_tasks:

    - apt:
        update_cache: yes

    - name: Disable IPv6
      blockinfile:
        path: /etc/sysctl.conf
        block: |
          net.ipv6.conf.all.disable_ipv6 = 1
          net.ipv6.conf.default.disable_ipv6 = 1
          net.ipv6.conf.lo.disable_ipv6 = 1
      notify: reboot

    - name: apply ipv6 disable
      command: sysctl -p
      become: yes

    - name: check ipv6 state
      shell: cat /proc/sys/net/ipv6/conf/all/disable_ipv6
      register: command_result
      failed_when: "'1' not in command_result.stdout"

    - apt:
        name: python-pip
  roles:
  - geerlingguy.pip

- import_playbook: postgres.yml
# todo: create synapse user
- import_playbook: synapse.yml