diff --git a/roles/database/tasks/configure_snmpd.yml b/roles/database/tasks/configure_snmpd.yml index f63ee55..c76685d 100644 --- a/roles/database/tasks/configure_snmpd.yml +++ b/roles/database/tasks/configure_snmpd.yml @@ -6,6 +6,22 @@ owner: "root" group: "root" when: postgres == true + register: postgres_script + +- name: database | snmpd | modify script part 1 + lineinfile: + path: "/etc/snmp/postgres" + regexp: "^\$cpg -u $DBuser --action dbstats | awk -F ' ' '$" + state: present + line: "$cpg --action dbstats | awk -F ' ' '" + when: postgres_script.rc == 0 + +- name: database | snmpd | modify script part 2 + replace: + path: "/etc/snmp/postgres" + regexp: "\\:" + replace: ":" + when: postgres_script.rc == 0 - include_tasks: install_check_postgres.yml when: postgres == true @@ -30,7 +46,7 @@ lineinfile: path: "/etc/snmp/snmpd.conf" state: present - line: "extend postgres /etc/snmp/postgres" + line: "extend postgres /usr/bin/sudo -u postgres /etc/snmp/postgres" insertafter: "# SECTION: Extends" notify: restart_snmpd when: postgres == true @@ -39,7 +55,7 @@ lineinfile: path: "/etc/snmp/snmpd.conf" state: present - line: "extend postgres /etc/snmp/postgres" + line: "extend mysql /etc/snmp/mysql" insertafter: "# SECTION: Extends" notify: restart_snmpd when: mysql == true \ No newline at end of file diff --git a/roles/server/files/sudoers b/roles/server/files/sudoers index 0cee923..61e48ea 100644 --- a/roles/server/files/sudoers +++ b/roles/server/files/sudoers @@ -1 +1,2 @@ Debian-snmp ALL = NOPASSWD: /etc/snmp/bind, /etc/snmp/fail2ban, /etc/snmp/docker-stats.sh, /etc/snmp/mailcow-dockerized-postfix +Debian-snmp ALL = (postgres) NOPASSWD: /etc/snmp/postgres \ No newline at end of file