-
Notifications
You must be signed in to change notification settings - Fork 18
Use the the original PostgreSQL configuration file #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
82efa2d
3637a0e
35930b0
0879c9f
9ee77fa
9790b98
743d5f3
dcaa4eb
8151508
5b1c41a
bc2b2ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,27 +22,78 @@ | |
| PGSETUP_INITDB_OPTIONS: >- | ||
| --encoding=UTF8 --locale=en_US.UTF-8 --auth-host=md5 | ||
|
|
||
| - name: postgres | postgresql config file | ||
| template: | ||
| - name: postgres | Check for presence of "Modified by ome postgresql ansible role" in file | ||
| ansible.builtin.lineinfile: | ||
| path: "{{ postgresql_dist_confdir }}/postgresql.conf" | ||
| line: "#Modified by ome postgresql ansible role" | ||
| state: absent | ||
| check_mode: yes | ||
| changed_when: false | ||
| register: config_file_changed | ||
|
sbesson marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: postgres | Check that the postgresql.conf.backup file exists | ||
| ansible.builtin.stat: | ||
| path: "{{ postgresql_dist_confdir }}/postgresql.conf.backup" | ||
| register: backup_result | ||
|
|
||
|
|
||
| # read the default postgresql configuration file | ||
| - name: postgres | get the postgres conf file contents | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.slurp: | ||
| src: "{{ postgresql_dist_confdir }}/postgresql.conf" | ||
| register: postgres_config_file_contents_o | ||
| when: | ||
| - not backup_result.stat.exists | ||
|
|
||
| # read the default postgresql configuration file | ||
| - name: postgres | get the postgres conf file contents from backup | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.slurp: | ||
| src: "{{ postgresql_dist_confdir }}/postgresql.conf.backup" | ||
| register: postgres_config_file_contents_b | ||
| when: backup_result.stat.exists | ||
|
|
||
| - set_fact: postgres_config_file_contents={{ postgres_config_file_contents_o }} | ||
| when: | ||
| - not backup_result.stat.exists | ||
|
|
||
| - set_fact: postgres_config_file_contents={{ postgres_config_file_contents_b }} | ||
| when: | ||
| - backup_result.stat.exists | ||
|
|
||
| - name: postgres | Copy a postgresql.conf to postgresql.conf.backup | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.copy: | ||
| src: "{{ postgresql_dist_confdir }}/postgresql.conf" | ||
| dest: "{{ postgresql_dist_confdir }}/postgresql.conf.backup" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly the logic, this is meant to create a one-off copy of the configuration file assuming the latter has not originally been modified (and templated) by Ansible.
|
||
| remote_src: yes | ||
| when: | ||
| - not backup_result.stat.exists | ||
| - config_file_changed.found | default(0) == 0 | ||
|
|
||
| - name: postgres | copy postgresql config file | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.template: | ||
| dest: >- | ||
| {{ postgresql_dist_confdir }}/postgresql.conf | ||
| src: "{{ postgresql_dist_conf_postgresql_src }}" | ||
| mode: 0644 | ||
| owner: "{{ postgresql_become_user }}" | ||
| notify: | ||
| - restart postgresql | ||
|
|
||
| become_user: "{{ postgresql_become_user }}" | ||
|
sbesson marked this conversation as resolved.
|
||
| when: | ||
| - config_file_changed.found | default(0) == 0 or backup_result.stat.exists | ||
|
|
||
| - name: postgres | configure client authorisation | ||
| become_user: "{{ postgresql_become_user }}" | ||
| template: | ||
| dest: "{{ postgresql_dist_confdir }}/pg_hba.conf" | ||
| src: pg_hba-conf.j2 | ||
| mode: 0640 | ||
| notify: | ||
| - restart postgresql | ||
|
|
||
| become_user: "{{ postgresql_become_user }}" | ||
|
|
||
| - name: postgres | start service | ||
| service: | ||
| enabled: true | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.