Compare commits
1 Commits
6fdc21291f
...
2b315cdb9d
Author | SHA1 | Date | |
---|---|---|---|
2b315cdb9d |
@ -8,7 +8,7 @@ postgresql_config_port: 5432
|
||||
|
||||
postgresql_base_config:
|
||||
listen_addresses: "{{ postgresql_config_listen_addresses }}"
|
||||
connect_socket: "{{ postgresql_config_connect_socket }}"
|
||||
unix_socket_directories: "{{ postgresql_config_unix_socket_directories }}"
|
||||
port: "{{ postgresql_config_port }}"
|
||||
postgresql_merged_config: >-2
|
||||
{{ postgresql_base_config | combine(
|
||||
|
@ -17,15 +17,14 @@ postgresql_pg_ident_conf_file: >-2
|
||||
{{ postgresql_config_path }}/pg_ident.conf
|
||||
postgresql_pg_hba_conf_file: >-2
|
||||
{{ postgresql_config_path }}/pg_hba.conf
|
||||
postgresql_admin_role: "{{ postgresql_user }}"
|
||||
postgresql_admin_role: "postgres"
|
||||
postgresql_admin_role_contype: local
|
||||
postgresql_admin_role_method: peer
|
||||
postgresql_admin_local_user: >-2
|
||||
{{ ansible_facts['user_id'] }}
|
||||
postgresql_admin_role_mapping_name: >-2
|
||||
{{ postgresql_admin_local_user }}_{{ postgresql_admin_role }}
|
||||
postgresql_admin_pg_ident_conf: >-2
|
||||
{{ postgresql_admin_role_mapping_name }}\t{{ postgresql_admin_local_user }}\t{{ postgresql_admin_role }}
|
||||
postgresql_admin_pg_ident_conf: "{{ postgresql_admin_role_mapping_name }}\t{{ postgresql_admin_local_user }}\t{{ postgresql_admin_role }}"
|
||||
postgresql_admin_pg_hba_conf_options: >-2
|
||||
map={{ postgresql_admin_role_mapping_name }}
|
||||
postgresql_superuser_password: ~
|
||||
|
@ -14,21 +14,31 @@
|
||||
- name: Ensure postgresql configuration is set
|
||||
community.postgresql.postgresql_set:
|
||||
name: "{{ option.key }}"
|
||||
value: "{{ option.value }}"
|
||||
value: "{{ pg_option_value }}"
|
||||
login_host: "{{ postgresql_login_host }}"
|
||||
login_port: "{{ postgresql_config_port }}"
|
||||
login_password: "{{ postgresql_superuser_password }}"
|
||||
loop: "{{ postgresql_merged_options | dict2items }}"
|
||||
loop: "{{ postgresql_merged_config | dict2items }}"
|
||||
loop_control:
|
||||
loop_var: option
|
||||
vars:
|
||||
pg_option_value: >-2
|
||||
{{
|
||||
(option.value | join(' '))
|
||||
if (option.value is iterable
|
||||
and option.value is not string
|
||||
and option.value is not mapping)
|
||||
else option.value
|
||||
}}
|
||||
register: postgresql_config_results
|
||||
|
||||
- name: Ensure postgresql configuration is reloaded
|
||||
community.postgresql.postgresql_query:
|
||||
db: "postgres"
|
||||
query: "SELECT pg_reload_conf();"
|
||||
login_host: "{{ postgresql_login_host }}"
|
||||
login_port: "{{ postgresql_config_port }}"
|
||||
login_password: "{{ postgresql_superuser_password }}"
|
||||
register: postgresql_config_results
|
||||
|
||||
- name: Ensure restart handler is fired if required
|
||||
debug:
|
||||
@ -39,7 +49,7 @@
|
||||
loop: "{{ postgresql_config_results.results }}"
|
||||
loop_control:
|
||||
loop_var: result
|
||||
label: "{{ result.option.name }}"
|
||||
label: "{{ result.option.key }}"
|
||||
vars:
|
||||
postgresql_login_host: >-2
|
||||
{{
|
||||
|
@ -69,10 +69,9 @@
|
||||
file: "initialize-docker.yml"
|
||||
when:
|
||||
- postgresql_state == 'present'
|
||||
- postgresql_global_data_info.stat.exists
|
||||
- not postgresql_global_data_info.stat.exists
|
||||
- postgresql_global_data_info.stat.isdir is defined
|
||||
- postgresql_global_data_info.stat.isdir
|
||||
# TODO: determine if initialization is needed
|
||||
- not postgresql_global_data_info.stat.isdir
|
||||
|
||||
- name: Ensure postgresql container '{{ postgresql_container_name }}' is {{ postgresql_container_state }}
|
||||
community.docker.docker_container:
|
||||
|
@ -20,7 +20,7 @@
|
||||
line: "# Ansible managed"
|
||||
- name: "{{ postgresql_pg_ident_conf_file }}"
|
||||
insert_after: "# Ansible managed"
|
||||
line: "{{ ansible_user }}_{{ postgresql_admin_role }}\t{{ ansible_user }}\t{{ postgresql_admin_role }}"
|
||||
line: "{{ postgresql_admin_pg_ident_conf }}"
|
||||
when: postgresql_state == 'present'
|
||||
|
||||
- name: Configure permissions for postgresql admin role
|
||||
@ -29,5 +29,5 @@
|
||||
contype: "{{ postgresql_admin_role_contype }}"
|
||||
users: "{{ postgresql_admin_role }}"
|
||||
method: "{{ postgresql_admin_role_method }}"
|
||||
options: "map={{ ansible_user }}_{{ postgresql_admin_role }}"
|
||||
options: "{{ postgresql_admin_pg_hba_conf_options }}"
|
||||
when: postgresql_state == 'present'
|
||||
|
Loading…
x
Reference in New Issue
Block a user