-
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 |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ postgresql_dist_redhat: | |
| (postgresql_package_version | length > 0) | | ||
| ternary('-' + postgresql_package_version, '') | ||
| }} | ||
| conf_sample_file: "/usr/pgsql-{{ postgresql_version }}/share/postgresql.conf.sample" | ||
|
|
||
| # Attributes are parsed and used to set facts at tasks/debian.yml. | ||
| # Debian variation, following the same principles of postgresql_dist_redhat | ||
|
|
@@ -62,4 +63,17 @@ postgresql_dist_debian: | |
| conf_postgresql_src: postgresql-conf.j2 | ||
| datadir: /var/lib/postgresql/{{ postgresql_version }}/main | ||
| basename: postgresql-{{ postgresql_version }} | ||
| conf_sample_file: "/usr/share/postgresql/{{ postgresql_version }}/postgresql.conf.sample" | ||
| service: postgresql | ||
|
|
||
| # conf_sample_file: sample configuration file, it should be copied during the installation by the installation package | ||
|
|
||
| # the following two variables are used to download link ofr the source to get the sample configuration file | ||
| # It will be used in case of the sample file is not find locally for any reason | ||
|
||
| versions_source_download: | ||
| 13: "13.15" | ||
| 14: "14.12" | ||
| 15: "15.7" | ||
| 16: "16.3" | ||
|
|
||
| source_download_linnk: "https://ftp.postgresql.org/pub/source/v{{ versions_source_download [postgresql_version] }}/postgresql-{{ versions_source_download [postgresql_version] }}.tar.gz" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| --- | ||
| # tasks file for ome.postgresql | ||
| ##Ansible managed | ||
sbesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - block: | ||
| - name: postgres | set permissions on data directory | ||
|
|
@@ -25,17 +26,16 @@ | |
| - 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" | ||
| line: "#Ansible managed" | ||
|
||
| state: absent | ||
| check_mode: yes | ||
| changed_when: false | ||
| register: config_file_changed | ||
sbesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: postgres | Check that the postgresql.conf.backup file exists | ||
| ansible.builtin.stat: | ||
| path: "{{ postgresql_dist_confdir }}/postgresql.conf.backup" | ||
| register: backup_result | ||
|
|
||
| path: "{{ postgresql_dist_confdir }}/postgresql.conf.org" | ||
| register: org_file | ||
|
|
||
| # read the default postgresql configuration file | ||
| - name: postgres | get the postgres conf file contents | ||
|
|
@@ -44,34 +44,70 @@ | |
| src: "{{ postgresql_dist_confdir }}/postgresql.conf" | ||
| register: postgres_config_file_contents_o | ||
| when: | ||
| - not backup_result.stat.exists | ||
| - not org_file.stat.exists | ||
|
|
||
| - name: Print the org_file.stat.exists | ||
| ansible.builtin.debug: | ||
| msg: | ||
| - System 1 {{ org_file.stat.exists }} and {{ config_file_changed.found }} | ||
| - "{{ postgresql_dist_confdir }}/postgresql.conf.org" | ||
| - "{{ postgresql_dist_redhat.conf_sample_file }}" | ||
|
|
||
| - name: postgres | get the orginal configuration file | ||
| become_user: "{{ postgresql_become_user }}" | ||
| import_tasks: org_config_file.yml | ||
| when: | ||
| - not org_file.stat.exists | ||
| - config_file_changed.found | ||
|
|
||
| - name: postgres | get the orginal configuration file | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.slurp: | ||
| src: "{{ postgresql_dist_confdir }}/postgresql.conf.org" | ||
| register: postgres_config_file_contents_c | ||
| when: | ||
| - not org_file.stat.exists | ||
| - config_file_changed.found | ||
|
|
||
|
|
||
| # read the default postgresql configuration file | ||
| - name: postgres | get the postgres conf file contents from backup | ||
| - name: postgres | get the postgres conf file contents from org | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.slurp: | ||
| src: "{{ postgresql_dist_confdir }}/postgresql.conf.backup" | ||
| src: "{{ postgresql_dist_confdir }}/postgresql.conf.org" | ||
| register: postgres_config_file_contents_b | ||
| when: backup_result.stat.exists | ||
| when: org_file.stat.exists | ||
|
|
||
|
|
||
| - set_fact: postgres_config_file_contents={{ postgres_config_file_contents_o }} | ||
| when: | ||
| - not backup_result.stat.exists | ||
| - not org_file.stat.exists | ||
|
|
||
| - set_fact: postgres_config_file_contents={{ postgres_config_file_contents_b }} | ||
| when: | ||
| - backup_result.stat.exists | ||
| - org_file.stat.exists | ||
|
|
||
| - name: postgres | Copy a postgresql.conf to postgresql.conf.backup | ||
| - set_fact: postgres_config_file_contents={{ postgres_config_file_contents_c }} | ||
| when: | ||
| - not org_file.stat.exists | ||
| - config_file_changed.found | ||
|
|
||
| - name: postgres | Copy a postgresql.conf to postgresql.conf.org | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.copy: | ||
| src: "{{ postgresql_dist_confdir }}/postgresql.conf" | ||
| dest: "{{ postgresql_dist_confdir }}/postgresql.conf.backup" | ||
| dest: "{{ postgresql_dist_confdir }}/postgresql.conf.org" | ||
| remote_src: yes | ||
| when: | ||
| - not backup_result.stat.exists | ||
| - not org_file.stat.exists | ||
| - config_file_changed.found | default(0) == 0 | ||
|
|
||
| - name: Print the org_file.stat.exists | ||
| ansible.builtin.debug: | ||
| msg: System {{ org_file.stat.exists }} and {{ config_file_changed.found }} | ||
| # when: | ||
| # - (not org_file.stat.exists and config_file_changed.found) or config_file_changed.found or org_file.stat.exists | ||
|
|
||
| - name: postgres | copy postgresql config file | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.template: | ||
|
|
@@ -82,8 +118,9 @@ | |
| owner: "{{ postgresql_become_user }}" | ||
| notify: | ||
| - restart postgresql | ||
| when: | ||
| - config_file_changed.found | default(0) == 0 or backup_result.stat.exists | ||
| when: (not org_file.stat.exists and config_file_changed.found) or not config_file_changed.found or org_file.stat.exists | ||
sbesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # - not org_file.stat.exists | ||
| # - config_file_changed.found | ||
|
|
||
| - name: postgres | configure client authorisation | ||
| become_user: "{{ postgresql_become_user }}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| --- | ||
| # get the original configuration file | ||
|
|
||
| - name: postgres | Check that the postgresql.conf.sample file exists (ubuntu) | ||
| ansible.builtin.stat: | ||
| path: "{{ postgresql_dist_debian.conf_sample_file }}" | ||
| register: conf_sample_file | ||
| when: ansible_os_family | lower == 'debian' | ||
|
|
||
| - name: postgres | postgres | Check that the postgresql.conf.sample file exists (redhat) | ||
sbesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ansible.builtin.stat: | ||
| path: "{{ postgresql_dist_redhat.conf_sample_file }}" | ||
| register: conf_sample_file | ||
| when: ansible_os_family | lower == 'redhat' | ||
|
|
||
| - name: postgres | copy the sample file to org | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.copy: | ||
| src: "{{ postgresql_dist_redhat.conf_sample_file }}" | ||
| dest: "{{ postgresql_dist_confdir }}/postgresql.conf.org" | ||
| when: | ||
| - conf_sample_file.stat.exists | ||
|
|
||
| - name: postgres | download the source code | ||
| ansible.builtin.get_url: | ||
| url: "{{ source_download_linnk }}" | ||
| dest: /tmp/postgresql.tar.gz | ||
| when: | ||
| - not conf_sample_file.stat.exists | ||
|
|
||
| - name: postgres | extract the files | ||
| ansible.builtin.unarchive: | ||
| src: /tmp/postgresql.tar.gz | ||
| dest: /tmp | ||
| remote_src: yes | ||
| when: | ||
| - not conf_sample_file.stat.exists | ||
|
|
||
| - name: postgres | copy the file to org file | ||
| become_user: "{{ postgresql_become_user }}" | ||
| ansible.builtin.copy: | ||
| src: "/tmp/postgresql-{{ versions_source_download [postgresql_version] }}/src/backend/utils/misc/postgresql.conf.sample" | ||
| dest: "{{ postgresql_dist_confdir }}/postgresql.conf.org" | ||
| when: | ||
| - not conf_sample_file.stat.exists | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #Modified by ome postgresql ansible role | ||
| #{{ ansible_managed }} | ||
|
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. See comment above. If we are using this as the marker of managed file, we'll need to use the same whitespace. Note also that |
||
| {{ postgres_config_file_contents['content'] | b64decode | regex_replace('}$', '') }} | ||
|
|
||
| listen_addresses = {{ postgresql_server_listen }} | ||
sbesson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.