2 - name: Bring up docker containers
6 postgres_barman_directory: 'test-postgres-11'
7 postgres_barman_server: postgres_barman
8 barman_rsync_password: "secret_rsync"
9 barman_rsync_allowed_hosts: 172.17.0.0/24
10 postgres_allowed_hosts:
13 postgres_replication_hosts:
17 - name: "{{ postgres_barman_server }}"
18 image: "python:3.7-stretch"
20 image: "python:3.7-stretch"
22 - "{{ postgres_barman_server }}"
24 image: "python:3.7-stretch"
26 - "{{ postgres_barman_server }}"
28 - name: postgres_three
29 image: "python:3.7-stretch"
31 - "{{ postgres_barman_server }}"
34 - role: provision_docker
35 provision_docker_inventory: "{{inventory}}"
36 provision_docker_use_docker_connection: true
44 - version: "{{ postgres_version }}"
50 barman_directory: "{{ postgres_barman_directory }}"
55 password: "secret_cocktail"
56 permissions: 'SUPERUSER'
57 - username: replicator
58 password: "secret_repli"
59 permissions: 'REPLICATION'
61 - dbname: test_database
64 - description: PostGis
66 - "postgresql-{{ postgres_version }}-postgis"
74 tags: provision_docker
76 - name: Group secondaries
82 - version: "{{ postgres_version }}"
88 barman_directory: "{{ postgres_barman_directory }}"
92 restore_directory: "{{ postgres_barman_directory }}"
93 replication_user: "replicator"
94 replication_password: "secret_repli"
99 tags: provision_docker
109 tags: provision_docker
117 - name: "{{ postgres_barman_directory }}"
118 description: 'Main database'
119 primary_host: postgres_one
120 primary_barman_password: "secret_cocktail"
122 ansible_group: db-all
123 retention_policy: 'RECOVERY WINDOW OF 7 DAYS'
126 tags: provision_docker
128 - name: Test installing Barman role
132 pre_tasks: &pre_tasks
133 - name: "Build hosts file"
134 shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts'
135 when: hostvars[inventory_hostname].ansible_default_ipv4.address is defined
137 - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})"
139 - { role: barman, tags: ['barman'] }
141 - name: Test installing Postgresql role
142 hosts: primary:secondary
145 postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
146 pre_tasks: *pre_tasks
148 - { role: ansible-postgresql-role, tags: ['postgres'] }
150 - name: Start postgres cluster
151 service: name=postgresql state=started
153 - name: Test connection to Postgres instances.
155 become_user: postgres
157 command: psql --port=5432 --command='select NOW()'
160 - name: Test running Postgresql role when database is started
162 hosts: primary:secondary
164 postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
165 pre_tasks: *pre_tasks
167 - { role: ansible-postgresql-role, tags: ['postgres'] }