-
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 7 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 |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ postgresql_server_auth: [] | |
| # Recursively reset the owner/group of the postgres datadir? | ||
| postgresql_server_chown_datadir: false | ||
|
|
||
| postgres_config_file_contents: '' | ||
| ###################################################################### | ||
| # Internal role variables, do not modify | ||
| ###################################################################### | ||
|
|
@@ -52,13 +53,27 @@ 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 | ||
| postgresql_dist_debian: | ||
| bindir: /usr/lib/postgresql/{{ postgresql_version }}/bin | ||
| confdir: /etc/postgresql/{{ postgresql_version }}/main | ||
| conf_postgresql_src: postgresql-conf-10-ubuntu.j2 | ||
| 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 | ||
|
|
@@ -22,27 +23,66 @@ | |
| 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 "#Ansible Managed" in file | ||
| ansible.builtin.lineinfile: | ||
| path: "{{ postgresql_dist_confdir }}/postgresql.conf" | ||
| 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.org file exists | ||
| ansible.builtin.stat: | ||
| path: "{{ postgresql_dist_confdir }}/postgresql.conf.org" | ||
| register: org_file | ||
|
|
||
| - 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.org" | ||
| remote_src: yes | ||
| when: | ||
| - not config_file_changed.found | ||
| - not org_file.stat.exists | ||
|
|
||
| - 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 | ||
|
|
||
| # 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.org" | ||
| register: postgres_config_file_contents_o | ||
|
|
||
| - set_fact: postgres_config_file_contents={{ postgres_config_file_contents_o }} | ||
|
|
||
| - 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.
Show resolved
Hide resolved
|
||
|
|
||
| - 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 | ||
|
|
||
| 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 | Check that the postgresql.conf.sample file exists (redhat) | ||
| 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 |
Uh oh!
There was an error while loading. Please reload this page.