|
36 | 36 | owner: "{{ postgresql_user_name }}"
|
37 | 37 | group: "{{ postgresql_user_name }}"
|
38 | 38 |
|
| 39 | +# lineinfile's behavior when `backrefs = True` is very odd. We don't want to overwrite include_dirs if it's already |
| 40 | +# properly set, but we don't know the exact format it will be in (with or without '=', with a comment at end of line, |
| 41 | +# etc.). So check for a match first and then add if there's no match. |
| 42 | +- name: Check for conf.d include in postgresql.conf |
| 43 | + lineinfile: |
| 44 | + line: 'why ansible ;(' |
| 45 | + # The '=' is optional but is present in postgresql.conf.sample, which Debian's sample is based off of (but include* |
| 46 | + # directive examples in the PostgreSQL docs don't use it). Also ignore comments and whitespace after the directive. |
| 47 | + regexp: '^include_dir(\s+|\s*=\s*)?''conf.d''\s*(#.*)?$' |
| 48 | + path: "{{ postgresql_conf_dir }}/postgresql.conf" |
| 49 | + backrefs: true |
| 50 | + check_mode: true |
| 51 | + changed_when: __postgresql_include_dir_result is not changed # yeah... |
| 52 | + register: __postgresql_include_dir_result |
| 53 | + when: "postgresql_version is version_compare('9.3', '>=')" |
| 54 | + |
39 | 55 | - name: Set conf.d include in postgresql.conf
|
40 | 56 | lineinfile:
|
41 | 57 | line: "include_dir 'conf.d'"
|
42 |
| - dest: "{{ postgresql_conf_dir }}/postgresql.conf" |
| 58 | + path: "{{ postgresql_conf_dir }}/postgresql.conf" |
43 | 59 | backup: yes
|
44 | 60 | notify: Reload PostgreSQL
|
45 |
| - when: "postgresql_version is version_compare('9.3', '>=')" |
46 |
| - |
| 61 | + when: "postgresql_version is version_compare('9.3', '>=') and __postgresql_include_dir_result is changed" |
47 | 62 |
|
48 | 63 | - name: Include 25ansible_postgresql.conf in postgresql.conf
|
49 | 64 | lineinfile:
|
|
0 commit comments