mirror of
https://github.com/famedly/ansible-collection-base
synced 2024-11-10 06:24:17 +00:00
fix(postgresql_client_access)!: use correct order for deprovisioning
The breakage comes from renaming postgresql_client_state to postgresql_client_access_state
This commit is contained in:
parent
fdab791c76
commit
66ef48220e
2 changed files with 47 additions and 9 deletions
|
@ -5,4 +5,4 @@ postgresql_config_path: "{{ postgresql_base_path }}/config"
|
||||||
postgresql_connect_socket: true
|
postgresql_connect_socket: true
|
||||||
|
|
||||||
postgresql_container_name: "postgresql"
|
postgresql_container_name: "postgresql"
|
||||||
postgresql_client_state: present
|
postgresql_client_access_state: "present"
|
||||||
|
|
|
@ -5,33 +5,39 @@
|
||||||
register: "postgresql_container"
|
register: "postgresql_container"
|
||||||
tags: ["deploy", "deploy-postgresql-client-access"]
|
tags: ["deploy", "deploy-postgresql-client-access"]
|
||||||
|
|
||||||
- name: "Ensure users are either present or absent"
|
- name: "Ensure users are present"
|
||||||
community.postgresql.postgresql_user:
|
community.postgresql.postgresql_user:
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
password: "{{ (item.state | default(postgresql_client_state) == 'present') | ternary(item.password, omit) }}"
|
password: "{{ item.password }}"
|
||||||
state: "{{ item.state | default(postgresql_client_state) }}"
|
state: "present"
|
||||||
login_host: "{{ postgresql_connection.login_host }}"
|
login_host: "{{ postgresql_connection.login_host }}"
|
||||||
login_port: "{{ postgresql_connection.login_port }}"
|
login_port: "{{ postgresql_connection.login_port }}"
|
||||||
login_password: "{{ postgresql_connection.login_password | default(omit) }}"
|
login_password: "{{ postgresql_connection.login_password | default(omit) }}"
|
||||||
loop: "{{ postgresql_client_access_users }}"
|
loop: "{{ postgresql_client_access_users }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.name }} ({{ item.state | default(postgresql_client_state) }})"
|
label: "{{ item.name }}"
|
||||||
|
vars:
|
||||||
|
item_state: "{{ item.state | default(postgresql_client_access_state) }}"
|
||||||
|
when: "item_state == 'present'"
|
||||||
tags: ["deploy", "deploy-postgresql-client-access"]
|
tags: ["deploy", "deploy-postgresql-client-access"]
|
||||||
|
|
||||||
- name: "Ensure databases are either present or absent"
|
- name: "Ensure databases are present"
|
||||||
community.postgresql.postgresql_db:
|
community.postgresql.postgresql_db:
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
owner: "{{ item.owner | default(omit) }}"
|
owner: "{{ item.owner | default(omit) }}"
|
||||||
lc_collate: "{{ item.lc_collate | default('C') }}"
|
lc_collate: "{{ item.lc_collate | default('C') }}"
|
||||||
lc_ctype: "{{ item.lc_ctype | default('C') }}"
|
lc_ctype: "{{ item.lc_ctype | default('C') }}"
|
||||||
template: "{{ item.template | default('template0') }}"
|
template: "{{ item.template | default('template0') }}"
|
||||||
state: "{{ item.state | default(postgresql_client_state) }}"
|
state: "present"
|
||||||
login_host: "{{ postgresql_connection.login_host }}"
|
login_host: "{{ postgresql_connection.login_host }}"
|
||||||
login_port: "{{ postgresql_connection.login_port }}"
|
login_port: "{{ postgresql_connection.login_port }}"
|
||||||
login_password: "{{ postgresql_connection.login_password | default(omit) }}"
|
login_password: "{{ postgresql_connection.login_password | default(omit) }}"
|
||||||
loop: "{{ postgresql_client_access_databases }}"
|
loop: "{{ postgresql_client_access_databases }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.name }} ({{ item.state | default(postgresql_client_state) }})"
|
label: "{{ item.name }}"
|
||||||
|
vars:
|
||||||
|
item_state: "{{ item.state | default(postgresql_client_access_state) }}"
|
||||||
|
when: "item_state == 'present'"
|
||||||
tags: ["deploy", "deploy-postgresql-client-access"]
|
tags: ["deploy", "deploy-postgresql-client-access"]
|
||||||
|
|
||||||
- name: "Ensure pg_hba.conf is up to date"
|
- name: "Ensure pg_hba.conf is up to date"
|
||||||
|
@ -44,10 +50,42 @@
|
||||||
options: "{{ item.options | default(omit) }}"
|
options: "{{ item.options | default(omit) }}"
|
||||||
address: "{{ item.address | default(omit) }}"
|
address: "{{ item.address | default(omit) }}"
|
||||||
netmask: "{{ item.netmask | default(omit) }}"
|
netmask: "{{ item.netmask | default(omit) }}"
|
||||||
state: "{{ item.state | default(postgresql_client_state) }}"
|
state: "{{ item_state }}"
|
||||||
loop: "{{ postgresql_client_access_hba_entries }}"
|
loop: "{{ postgresql_client_access_hba_entries }}"
|
||||||
|
vars:
|
||||||
|
item_state: "{{ item.state | default(postgresql_client_access_state) }}"
|
||||||
notify: "postgresql_container_restart"
|
notify: "postgresql_container_restart"
|
||||||
tags: ["deploy", "deploy-postgresql-client-access"]
|
tags: ["deploy", "deploy-postgresql-client-access"]
|
||||||
|
|
||||||
|
- name: "Ensure databases are absent"
|
||||||
|
community.postgresql.postgresql_db:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
state: "absent"
|
||||||
|
login_host: "{{ postgresql_connection.login_host }}"
|
||||||
|
login_port: "{{ postgresql_connection.login_port }}"
|
||||||
|
login_password: "{{ postgresql_connection.login_password | default(omit) }}"
|
||||||
|
loop: "{{ postgresql_client_access_databases }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
|
vars:
|
||||||
|
item_state: "{{ item.state | default(postgresql_client_access_state) }}"
|
||||||
|
when: "item_state == 'absent'"
|
||||||
|
tags: ["deploy", "deploy-postgresql-client-access"]
|
||||||
|
|
||||||
|
- name: "Ensure users are absent"
|
||||||
|
community.postgresql.postgresql_user:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
state: "absent"
|
||||||
|
login_host: "{{ postgresql_connection.login_host }}"
|
||||||
|
login_port: "{{ postgresql_connection.login_port }}"
|
||||||
|
login_password: "{{ postgresql_connection.login_password | default(omit) }}"
|
||||||
|
loop: "{{ postgresql_client_access_users }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
|
vars:
|
||||||
|
item_state: "{{ item.state | default(postgresql_client_access_state) }}"
|
||||||
|
when: "item_state == 'absent'"
|
||||||
|
tags: ["deploy", "deploy-postgresql-client-access"]
|
||||||
|
|
||||||
- name: "Flush handlers to ensure pg_hba updates are propagated in time"
|
- name: "Flush handlers to ensure pg_hba updates are propagated in time"
|
||||||
ansible.builtin.meta: "flush_handlers"
|
ansible.builtin.meta: "flush_handlers"
|
||||||
|
|
Loading…
Reference in a new issue