2 - name: Bring up docker containers
5 postgres_barman_directory: "test-postgres-{{ postgres_version }}"
6 postgres_barman_server: postgres_barman
7 barman_rsync_password: "secret_rsync"
8 barman_rsync_allowed_hosts: 172.17.0.0/24
9 postgres_allowed_hosts:
12 postgres_replication_hosts:
16 - name: "{{ postgres_barman_server }}"
17 image: "python:3.7-{{ debian_release }}"
19 image: "python:3.7-{{ debian_release }}"
21 - "{{ postgres_barman_server }}"
23 image: "python:3.7-{{ debian_release }}"
25 - "{{ postgres_barman_server }}"
27 - name: postgres_three
28 image: "python:3.7-{{ debian_release }}"
30 - "{{ postgres_barman_server }}"
33 - role: provision_docker
35 provision_docker_inventory: "{{inventory}}"
36 provision_docker_use_docker_connection: true
37 ansible_connection: local
38 ansible_python_interpreter: "{{ansible_playbook_python}}"
46 - version: "{{ postgres_version }}"
52 barman_directory: "{{ postgres_barman_directory }}"
57 password: "secret_cocktail"
58 permissions: 'SUPERUSER'
59 - username: replicator
60 password: "secret_repli"
61 permissions: 'REPLICATION'
63 - dbname: test_database
66 - description: PostGis
68 - "postgresql-{{ postgres_version }}-postgis-3"
76 tags: provision_docker
78 - name: Group secondaries
84 - version: "{{ postgres_version }}"
90 barman_directory: "{{ postgres_barman_directory }}"
94 restore_directory: "{{ postgres_barman_directory }}"
95 replication_user: "replicator"
96 replication_password: "secret_repli"
101 tags: provision_docker
111 tags: provision_docker
119 - name: "{{ postgres_barman_directory }}"
120 description: 'Main database'
121 primary_host: postgres_one
122 postgres_barman_password: "secret_cocktail"
124 standby_hosts: "{{ groups['db-all'][1:] }}"
125 retention_policy: 'RECOVERY WINDOW OF 7 DAYS'
128 tags: provision_docker
130 - name: Test installing Postgresql role
131 hosts: primary:secondary
134 postgres_listen_addresses: ["{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"]
135 pre_tasks: &pre_tasks
136 - name: "Build hosts file"
137 shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts'
138 when: hostvars[inventory_hostname].ansible_default_ipv4.address is defined
140 - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})"
142 - { role: ansible-postgresql-role, tags: ['postgres'] }
144 - name: Start postgres cluster
145 service: name=postgresql state=started
147 - name: Test connection to Postgres instances.
149 become_user: postgres
151 command: psql --port=5432 --command='select NOW()'
154 - name: Test installing Barman role
158 pre_tasks: *pre_tasks
160 - { role: barman, tags: ['barman'] }
162 - name: Test running Postgresql role when database is started
164 hosts: primary:secondary
166 postgres_listen_addresses: ["{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"]
167 pre_tasks: *pre_tasks
169 - { role: ansible-postgresql-role, tags: ['postgres'] }