diff --git a/tasks/plugins_postgresql.yml b/tasks/plugins_postgresql.yml index 6adafe5..8a0a21e 100644 --- a/tasks/plugins_postgresql.yml +++ b/tasks/plugins_postgresql.yml @@ -3,8 +3,10 @@ - name: plugins_postgresql | Enable local peer access for root user ansible.builtin.lineinfile: path: "{{ bareos_fd_plugin_psql_config_hba }}" - line: "local all root peer" - regexp: '^local\\s+all\\s+root\\s+peer$' # match for any amount of spaces + line: >- + local all root peer # Ansible managed: + Do NOT remove line manually! Managed by bareos_fd role + regexp: '^local\s+all\s+root\s+peer' # match for any amount of spaces state: present backup: true notify: Reload postgresql @@ -17,16 +19,32 @@ mode: "0751" path: "{{ bareos_fd_plugin_psql_wal_archive }}" -- name: plugins_postgresql | Enable archive mode in config - ansible.builtin.blockinfile: +- name: plugins_postgresql | Make sure postgres conf.d dir is present + ansible.builtin.file: + state: directory + owner: postgres + group: postgres + mode: "0755" + path: "{{ bareos_fd_plugin_psql_root_dir }}/conf.d" + +- name: plugins_postgresql | Include conf.d dir in postgresql.conf + ansible.builtin.lineinfile: path: "{{ bareos_fd_plugin_psql_config }}" - block: | - archive_mode = on - archive_command = 'test ! -f {{ bareos_fd_plugin_psql_wal_archive }}/%f && cp %p {{ bareos_fd_plugin_psql_wal_archive }}/%f' + line: >- + include_dir = 'conf.d' # Ansible managed: + Do NOT remove line manually! Managed by bareos_fd role + regexp: '^#?(\s+)?include_dir' # match also commented line state: present backup: true notify: Reload postgresql +- name: plugins_postgresql | Deploy config for wal archive mode + ansible.builtin.template: + src: "templates/plugin_postgresql_bareos_wal_archive.conf.j2" + dest: "{{ bareos_fd_plugin_psql_root_dir }}/conf.d/bareos_postgresql_wal_archive.conf" + backup: true + notify: Reload postgresql + - name: plugins_postgresql | Create plugin_defaults file ansible.builtin.template: src: "templates/plugin_postgresql_defaults.ini.j2" diff --git a/templates/plugin_postgresql_bareos_wal_archive.conf.j2 b/templates/plugin_postgresql_bareos_wal_archive.conf.j2 new file mode 100644 index 0000000..c3d1a58 --- /dev/null +++ b/templates/plugin_postgresql_bareos_wal_archive.conf.j2 @@ -0,0 +1,3 @@ +{{ ansible_managed | comment }} +archive_mode = on +archive_command = 'test ! -f {{ bareos_fd_plugin_psql_wal_archive | default("") }}/%f && cp %p {{ bareos_fd_plugin_psql_wal_archive | default("") }}/%f'