Debian Codegraph @

ansible_collections/community/postgresql/tests/integration/targets/postgresql_subscription/tasks/setup_publication.yml

raw
1 # Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <[email protected]>
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # Preparation for further tests of postgresql_subscription module.
4
5 - vars:
6 task_parameters: &task_parameters
7 become_user: '{{ pg_user }}'
8 become: true
9 register: result
10 pg_parameters: &pg_parameters
11 login_user: '{{ pg_user }}'
12 login_db: '{{ test_db }}'
13
14 block:
15 - name: postgresql_publication - create test db
16 <<: *task_parameters
17 postgresql_db:
18 login_user: '{{ pg_user }}'
19 login_port: '{{ item }}'
20 maintenance_db: '{{ db_default }}'
21 name: '{{ test_db }}'
22 loop:
23 - '{{ primary_port }}'
24 - '{{ replica_port }}'
25
26 - name: postgresql_publication - create test role
27 <<: *task_parameters
28 postgresql_user:
29 <<: *pg_parameters
30 login_port: '{{ item }}'
31 name: '{{ replication_role }}'
32 password: '{{ replication_pass }}'
33 role_attr_flags: LOGIN,REPLICATION
34 loop:
35 - '{{ primary_port }}'
36 - '{{ replica_port }}'
37
38 - name: postgresql_publication - create test table
39 <<: *task_parameters
40 postgresql_table:
41 <<: *pg_parameters
42 login_port: '{{ item }}'
43 name: '{{ test_table1 }}'
44 columns:
45 - id int
46 loop:
47 - '{{ primary_port }}'
48 - '{{ replica_port }}'
49
50 - name: postgresql_publication - create publication
51 <<: *task_parameters
52 postgresql_publication:
53 <<: *pg_parameters
54 login_port: '{{ primary_port }}'
55 name: '{{ test_pub }}'
56
57 - assert:
58 that:
59 - result is changed
60 - result.exists == true
61 - result.queries == ["CREATE PUBLICATION \"{{ test_pub }}\" FOR ALL TABLES"]
62 - result.owner == '{{ pg_user }}'
63 - result.alltables == true
64 - result.tables == []
65 - result.parameters.publish != {}
66
67 - name: postgresql_publication - create one more publication
68 <<: *task_parameters
69 postgresql_publication:
70 <<: *pg_parameters
71 login_port: '{{ primary_port }}'
72 name: '{{ test_pub2 }}'
73
74 - name: postgresql_publication - check the publication was created
75 <<: *task_parameters
76 postgresql_query:
77 <<: *pg_parameters
78 login_port: '{{ primary_port }}'
79 query: >
80 SELECT * FROM pg_publication WHERE pubname = '{{ test_pub }}'
81 AND pubowner = '10' AND puballtables = 't'
82
83 - assert:
84 that:
85 - result.rowcount == 1