Skip to content

Commit

Permalink
Terminology: replace master with primary (#67)
Browse files Browse the repository at this point in the history
* Terminology: replace master with primary

* Fix CI
  • Loading branch information
Andersson007 authored Mar 13, 2021
1 parent ae30626 commit 5b87db2
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion plugins/modules/postgresql_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ def get_settings(self):
self.pg_info["settings"] = set_dict

def get_repl_info(self):
"""Get information about replication if the server is a master."""
"""Get information about replication if the server is a primary."""
# Check that pg_replication_slots exists:
res = self.__exec_sql("SELECT EXISTS (SELECT 1 FROM "
"information_schema.tables "
Expand Down
6 changes: 3 additions & 3 deletions plugins/modules/postgresql_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def create(self, connparams, publications, subsparams, check_mode=True):
Args:
connparams (str): Connection string in libpq style.
publications (list): Publications on the master to use.
publications (list): Publications on the primary to use.
subsparams (str): Parameters string in WITH () clause style.
Kwargs:
Expand All @@ -368,7 +368,7 @@ def update(self, connparams, publications, subsparams, check_mode=True):
Args:
connparams (str): Connection string in libpq style.
publications (list): Publications on the master to use.
publications (list): Publications on the primary to use.
subsparams (dict): Dictionary of optional parameters.
Kwargs:
Expand Down Expand Up @@ -504,7 +504,7 @@ def __set_publications(self, publications, check_mode=True):
"""Update publications.
Args:
publications (list): Publications on the master to use.
publications (list): Publications on the primary to use.
Kwargs:
check_mode (bool): If True, don't actually change anything,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
pg_user: postgres
db_default: postgres
master_port: 5433
primary_port: 5433
replica_port: 5434

test_table1: acme1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
publications: '{{ test_pub }}'
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand All @@ -39,7 +39,7 @@
publications: '{{ test_pub2 }}'
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand Down Expand Up @@ -143,7 +143,7 @@
postgresql_info:
<<: *pg_parameters
login_db: '{{ test_db }}'
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
trust_input: yes

- assert:
Expand All @@ -165,7 +165,7 @@
postgresql_info:
<<: *pg_parameters
login_db: '{{ test_db }}'
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
trust_input: no
session_role: 'curious.anonymous"; SELECT * FROM information_schema.tables; --'
register: result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
<<: *task_parameters
postgresql_db:
login_user: '{{ pg_user }}'
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
maintenance_db: '{{ db_default }}'
name: '{{ test_db }}'

- name: Create test role
<<: *task_parameters
postgresql_user:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
name: '{{ replication_role }}'
password: '{{ replication_pass }}'
role_attr_flags: LOGIN,REPLICATION
Expand All @@ -33,14 +33,14 @@
<<: *task_parameters
postgresql_table:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
name: '{{ test_table1 }}'
columns:
- id int

- name: Master - dump schema
<<: *task_parameters
shell: pg_dumpall -p '{{ master_port }}' -s > /tmp/schema.sql
shell: pg_dumpall -p '{{ primary_port }}' -s > /tmp/schema.sql

- name: Replicat restore schema
<<: *task_parameters
Expand All @@ -50,12 +50,12 @@
<<: *task_parameters
postgresql_publication:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
name: '{{ test_pub }}'

- name: Create publication
<<: *task_parameters
postgresql_publication:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
name: '{{ test_pub2 }}'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pg_user: postgres
db_default: postgres
master_port: 5433
primary_port: 5433
replica_port: 5434

test_table1: acme1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
publications: '{{ test_pub }}'
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand All @@ -47,7 +47,7 @@
that:
- result is changed
- result.name == '{{ test_subscription }}'
- result.queries == ["CREATE SUBSCRIPTION test CONNECTION 'host=127.0.0.1 port={{ master_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }}' PUBLICATION {{ test_pub }}"]
- result.queries == ["CREATE SUBSCRIPTION test CONNECTION 'host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }}' PUBLICATION {{ test_pub }}"]
- result.exists == true
- result.initial_state == {}
- result.final_state.owner == '{{ pg_user }}'
Expand All @@ -57,7 +57,7 @@
- result.final_state.slotname == '{{ test_subscription }}'
- result.final_state.conninfo.dbname == '{{ test_db }}'
- result.final_state.conninfo.host == '127.0.0.1'
- result.final_state.conninfo.port == {{ master_port }}
- result.final_state.conninfo.port == {{ primary_port }}
- result.final_state.conninfo.user == '{{ replication_role }}'
- result.final_state.conninfo.password == '{{ replication_pass }}'

Expand Down Expand Up @@ -143,7 +143,7 @@
owner: '{{ test_role1 }}'
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand Down Expand Up @@ -267,7 +267,7 @@
trust_input: no
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand Down Expand Up @@ -350,7 +350,7 @@
publications: '{{ test_pub }}'
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand All @@ -363,7 +363,7 @@
that:
- result is changed
- result.name == '{{ test_subscription }}'
- result.queries == ["CREATE SUBSCRIPTION test CONNECTION 'host=127.0.0.1 port={{ master_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }}' PUBLICATION {{ test_pub }} WITH (enabled = false, synchronous_commit = false)"]
- result.queries == ["CREATE SUBSCRIPTION test CONNECTION 'host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }}' PUBLICATION {{ test_pub }} WITH (enabled = false, synchronous_commit = false)"]
- result.exists == true
- result.final_state.enabled == false
- result.final_state.synccommit == false
Expand Down Expand Up @@ -554,7 +554,7 @@
state: present
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand All @@ -566,7 +566,7 @@
that:
- result is changed
- result.name == '{{ test_subscription }}'
- result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} CONNECTION 'host=127.0.0.1 port={{ master_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }} connect_timeout={{ conn_timeout }}'"]
- result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} CONNECTION 'host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }} connect_timeout={{ conn_timeout }}'"]
- result.initial_state.conninfo == result.final_state.conninfo

- name: Change conninfo
Expand All @@ -578,7 +578,7 @@
state: present
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand All @@ -589,7 +589,7 @@
that:
- result is changed
- result.name == '{{ test_subscription }}'
- result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} CONNECTION 'host=127.0.0.1 port={{ master_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }} connect_timeout={{ conn_timeout }}'"]
- result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} CONNECTION 'host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }} connect_timeout={{ conn_timeout }}'"]
- result.initial_state.conninfo != result.final_state.conninfo

- name: Check
Expand All @@ -601,7 +601,7 @@

- assert:
that:
- result.query_result[0].subconninfo == "host=127.0.0.1 port={{ master_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }} connect_timeout={{ conn_timeout }}"
- result.query_result[0].subconninfo == "host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }} connect_timeout={{ conn_timeout }}"

- name: Try to change conninfo again with the same values
<<: *task_parameters
Expand All @@ -612,7 +612,7 @@
state: present
connparams:
host: 127.0.0.1
port: '{{ master_port }}'
port: '{{ primary_port }}'
user: '{{ replication_role }}'
password: '{{ replication_pass }}'
dbname: '{{ test_db }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
<<: *task_parameters
postgresql_db:
login_user: '{{ pg_user }}'
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
maintenance_db: '{{ db_default }}'
name: '{{ test_db }}'

- name: postgresql_publication - create test role
<<: *task_parameters
postgresql_user:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
name: '{{ replication_role }}'
password: '{{ replication_pass }}'
role_attr_flags: LOGIN,REPLICATION
Expand All @@ -33,14 +33,14 @@
<<: *task_parameters
postgresql_table:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
name: '{{ test_table1 }}'
columns:
- id int

- name: Master - dump schema
- name: Primary - dump schema
<<: *task_parameters
shell: pg_dumpall -p '{{ master_port }}' -s > /tmp/schema.sql
shell: pg_dumpall -p '{{ primary_port }}' -s > /tmp/schema.sql

- name: Replicat restore schema
<<: *task_parameters
Expand All @@ -50,7 +50,7 @@
<<: *task_parameters
postgresql_publication:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
name: '{{ test_pub }}'

- assert:
Expand All @@ -67,14 +67,14 @@
<<: *task_parameters
postgresql_publication:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
name: '{{ test_pub2 }}'

- name: postgresql_publication - check the publication was created
<<: *task_parameters
postgresql_query:
<<: *pg_parameters
login_port: '{{ master_port }}'
login_port: '{{ primary_port }}'
query: >
SELECT * FROM pg_publication WHERE pubname = '{{ test_pub }}'
AND pubowner = '10' AND puballtables = 't'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ packages_to_remove:
- python3-psycopg2

# Master specific defaults:
master_root_dir: '/var/lib/pgsql/master'
master_data_dir: '{{ master_root_dir }}/data'
master_postgresql_conf: '{{ master_data_dir }}/postgresql.conf'
master_pg_hba_conf: '{{ master_data_dir }}/pg_hba.conf'
master_port: 5433
primary_root_dir: '/var/lib/pgsql/primary'
primary_data_dir: '{{ primary_root_dir }}/data'
primary_postgresql_conf: '{{ primary_data_dir }}/postgresql.conf'
primary_pg_hba_conf: '{{ primary_data_dir }}/pg_hba.conf'
primary_port: 5433

# Replica specific defaults:
replica_root_dir: '/var/lib/pgsql/replica'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
become_user: '{{ pg_user }}'
shell: '{{ pg_ctl }} -D {{ item.datadir }} -o "-p {{ item.port }}" -m immediate stop'
loop:
- { datadir: '{{ master_data_dir }}', port: '{{ master_port }}' }
- { datadir: '{{ primary_data_dir }}', port: '{{ primary_port }}' }
- { datadir: '{{ replica_data_dir }}', port: '{{ replica_port }}' }
listen: stop postgresql

Expand All @@ -18,6 +18,6 @@
state: absent
path: "{{ item }}"
loop:
- "{{ master_root_dir }}"
- "{{ primary_root_dir }}"
- "{{ replica_root_dir }}"
listen: cleanup postgresql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# Setup PostgreSQL master-standby replication into one container:
# Setup PostgreSQL primary-standby replication into one container:
- import_tasks: setup_postgresql_cluster.yml
when:
- ansible_distribution == 'Ubuntu'
Expand Down
Loading

0 comments on commit 5b87db2

Please sign in to comment.