X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=test%2Fmain.yml;h=6a819d833f309b1f6766610e875c693be4cb2153;hb=ebe451adda84672f9872187164df279dbfed7a35;hp=625819985ceff6bc51a2714e843851aeaf98987f;hpb=5a084b7b21ac88f96ad36f0254c9e27666d41a02;p=github%2Ffretlink%2Fansible-postgresql-role.git diff --git a/test/main.yml b/test/main.yml index 6258199..6a819d8 100644 --- a/test/main.yml +++ b/test/main.yml @@ -2,8 +2,7 @@ - name: Bring up docker containers hosts: localhost vars: &common_vars - postgres_version: 11 - postgres_barman_directory: 'test-postgres-11' + postgres_barman_directory: "test-postgres-{{ postgres_version }}" postgres_barman_server: postgres_barman barman_rsync_password: "secret_rsync" barman_rsync_allowed_hosts: 172.17.0.0/24 @@ -15,25 +14,28 @@ range: 172.17.0.0/24 inventory: - name: "{{ postgres_barman_server }}" - image: "python:3.7-stretch" + image: "python:3.7-{{ debian_release }}" - name: postgres_one - image: "python:3.7-stretch" + image: "python:3.7-{{ debian_release }}" links: - "{{ postgres_barman_server }}" - name: postgres_two - image: "python:3.7-stretch" + image: "python:3.7-{{ debian_release }}" links: - "{{ postgres_barman_server }}" - postgres_one - name: postgres_three - image: "python:3.7-stretch" + image: "python:3.7-{{ debian_release }}" links: - "{{ postgres_barman_server }}" - postgres_one roles: - role: provision_docker - provision_docker_inventory: "{{inventory}}" - provision_docker_use_docker_connection: true + vars: + provision_docker_inventory: "{{inventory}}" + provision_docker_use_docker_connection: true + ansible_connection: local + ansible_python_interpreter: "{{ansible_playbook_python}}" tasks: - name: Group primary add_host: @@ -49,12 +51,25 @@ archive_enabled: True barman_directory: "{{ postgres_barman_directory }}" users: + - username: tester + password: tester - username: barman password: "secret_cocktail" permissions: 'SUPERUSER' - username: replicator password: "secret_repli" permissions: 'REPLICATION' + databases: + - dbname: test_database + owner: tester + extensions: + - description: PostGis + apt_deps: + - "postgresql-{{ postgres_version }}-postgis-3" + names: + - postgis + - postgis_topology + - btree_gist with_items: - postgres_one @@ -104,33 +119,25 @@ - name: "{{ postgres_barman_directory }}" description: 'Main database' primary_host: postgres_one - primary_barman_password: "secret_cocktail" + postgres_barman_password: "secret_cocktail" backup_method: rsync - ansible_group: db-all + standby_hosts: "{{ groups['db-all'][1:] }}" retention_policy: 'RECOVERY WINDOW OF 7 DAYS' with_items: - postgres_barman tags: provision_docker -- name: Test installing Barman role - hosts: barman - connection: docker - vars: {} - pre_tasks: &pre_tasks - - name: "Build hosts file" - shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts' - when: hostvars[inventory_hostname].ansible_default_ipv4.address is defined - - - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})" - roles: - - { role: barman, tags: ['barman'] } - - name: Test installing Postgresql role hosts: primary:secondary connection: docker vars: - postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}" - pre_tasks: *pre_tasks + postgres_listen_addresses: ["{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"] + pre_tasks: &pre_tasks + - name: "Build hosts file" + shell: 'echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }} {{inventory_hostname}}" >> /etc/hosts' + when: hostvars[inventory_hostname].ansible_default_ipv4.address is defined + + - debug: msg="Running on host {{inventory_hostname}} ({{ hostvars[inventory_hostname].ansible_default_ipv4.address }})" roles: - { role: ansible-postgresql-role, tags: ['postgres'] } tasks: @@ -144,11 +151,19 @@ command: psql --port=5432 --command='select NOW()' +- name: Test installing Barman role + hosts: barman + connection: docker + vars: {} + pre_tasks: *pre_tasks + roles: + - { role: barman, tags: ['barman'] } + - name: Test running Postgresql role when database is started connection: docker hosts: primary:secondary vars: - postgres_listen_addresses: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}" + postgres_listen_addresses: ["{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"] pre_tasks: *pre_tasks roles: - { role: ansible-postgresql-role, tags: ['postgres'] }