community / community.general / 0.2.1 / module / postgresql_subscription Add, update, or remove PostgreSQL subscription | "added in version" 0.2.0 of community.general" Authors: Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>community.general.postgresql_subscription (0.2.1) — module
Install with ansible-galaxy collection install community.general:==0.2.1
collections: - name: community.general version: 0.2.1
Add, update, or remove PostgreSQL subscription.
- name: > Create acme subscription in mydb database using acme_publication and the following connection parameters to connect to the publisher. Set the subscription owner as alice. postgresql_subscription: db: mydb name: acme state: present publications: acme_publication owner: alice connparams: host: 127.0.0.1 port: 5432 user: repl password: replpass dbname: mydb
- name: Assuming that acme subscription exists, try to change conn parameters postgresql_subscription: db: mydb name: acme connparams: host: 127.0.0.1 port: 5432 user: repl password: replpass connect_timeout: 100
- name: Refresh acme publication postgresql_subscription: db: mydb name: acme state: refresh
- name: Drop acme subscription from mydb with dependencies (cascade=yes) postgresql_subscription: db: mydb name: acme state: absent cascade: yes
- name: Assuming that acme subscription exists and enabled, disable the subscription postgresql_subscription: db: mydb name: acme state: present subsparams: enabled: no
db: aliases: - login_db description: - Name of the database to connect to and where the subscription state will be changed. required: true type: str name: description: - Name of the subscription to add, update, or remove. required: true type: str port: aliases: - login_port default: 5432 description: - Database port to connect to. type: int owner: description: - Subscription owner. - If I(owner) is not defined, the owner will be set as I(login_user) or I(session_role). - Ignored when I(state) is not C(present). type: str state: choices: - absent - present - refresh default: present description: - The subscription state. - C(present) implies that if I(name) subscription doesn't exist, it will be created. - C(absent) implies that if I(name) subscription exists, it will be removed. - C(refresh) implies that if I(name) subscription exists, it will be refreshed. Fetch missing table information from publisher. Always returns ``changed`` is ``True``. This will start replication of tables that were added to the subscribed-to publications since the last invocation of REFRESH PUBLICATION or since CREATE SUBSCRIPTION. The existing data in the publications that are being subscribed to should be copied once the replication starts. - For more information about C(refresh) see U(https://www.postgresql.org/docs/current/sql-altersubscription.html). type: str ca_cert: aliases: - ssl_rootcert description: - Specifies the name of a file containing SSL certificate authority (CA) certificate(s). - If the file exists, the server's certificate will be verified to be signed by one of these authorities. type: str cascade: default: false description: - Drop subscription dependencies. Has effect with I(state=absent) only. - Ignored when I(state) is not C(absent). type: bool ssl_mode: choices: - allow - disable - prefer - require - verify-ca - verify-full default: prefer description: - Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. - See U(https://www.postgresql.org/docs/current/static/libpq-ssl.html) for more information on the modes. - Default of C(prefer) matches libpq default. type: str connparams: description: - The connection dict param-value to connect to the publisher. - For more information see U(https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING). - Ignored when I(state) is not C(present). type: dict login_host: description: - Host running the database. type: str login_user: default: postgres description: - The username used to authenticate with. type: str subsparams: description: - Dictionary of optional parameters for a subscription, e.g. copy_data, enabled, create_slot, etc. - For update the subscription allowed keys are C(enabled), C(slot_name), C(synchronous_commit), C(publication_name). - See available parameters to create a new subscription on U(https://www.postgresql.org/docs/current/sql-createsubscription.html). - Ignored when I(state) is not C(present). type: dict trust_input: default: true description: - If C(no), check whether values of parameters I(name), I(publications), I(owner), I(session_role), I(connparams), I(subsparams) are potentially dangerous. - It makes sense to use C(yes) only when SQL injections via the parameters are possible. type: bool version_added: 0.2.0 version_added_collection: community.general publications: description: - The publication names on the publisher to use for the subscription. - Ignored when I(state) is not C(present). elements: str type: list session_role: description: - Switch to session_role after connecting. The specified session_role must be a role that the current login_user is a member of. - Permissions checking for SQL commands is carried out as though the session_role were the one that had logged in originally. type: str version_added: 0.2.0 version_added_collection: community.general login_password: description: - The password used to authenticate with. type: str login_unix_socket: description: - Path to a Unix domain socket for local connections. type: str
exists: description: - Flag indicates the subscription exists or not at the end of runtime. returned: always sample: true type: bool final_state: description: Subscription configuration at the end of runtime. returned: always sample: conninfo: {} enabled: true owner: postgres slotname: test synccommit: true type: dict initial_state: description: Subscription configuration at the beginning of runtime. returned: always sample: conninfo: {} enabled: true owner: postgres slotname: test synccommit: true type: dict name: description: - Name of the subscription. returned: always sample: acme type: str queries: description: List of executed queries. returned: always sample: - DROP SUBSCRIPTION "mysubscription" type: str