From 082222119007c6a8f12581f2b99f371b2dea516b Mon Sep 17 00:00:00 2001 From: Ray Lyon <36998292+skoobasteeve@users.noreply.github.com> Date: Sat, 24 Apr 2021 19:33:25 -0400 Subject: [PATCH] fixed snmpd logging verbosity --- ansible/playbook-snmp.yml | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/ansible/playbook-snmp.yml b/ansible/playbook-snmp.yml index f3c73f8..058ebe8 100644 --- a/ansible/playbook-snmp.yml +++ b/ansible/playbook-snmp.yml @@ -1,8 +1,8 @@ --- -# Expects snmpd.conf in same directory +# Expects snmpd.conf and snmpd_arm.conf in same directory - name: configure snmp hosts: active - remote_user: + remote_user: raylyon become: yes vars: pihole01_key: "" @@ -75,16 +75,18 @@ mode: '755' when: pihole.stat.exists - name: add api key to pihole script for pihole01 - replace: + ansible.builtin.lineinfile: path: "/etc/snmp/pi-hole" - regexp: 'API_AUTH_KEY=""' - replace: 'API_AUTH_KEY="{{ pihole01_key }}"' + regexp: '^API_AUTH_KEY=' + line: 'API_AUTH_KEY="{{ pihole01_key }}"' + backrefs: yes when: ansible_hostname == "pihole01" - name: add api key to pihole script for pihole02 - replace: + ansible.builtin.lineinfile: path: "/etc/snmp/pi-hole" - regexp: 'API_AUTH_KEY=""' - replace: 'API_AUTH_KEY="{{ pihole02_key }}"' + regexp: '^API_AUTH_KEY=' + line: 'API_AUTH_KEY="{{ pihole02_key }}"' + backrefs: yes when: ansible_hostname == "pihole02" - name: enable extend nfs-server ansible.builtin.lineinfile: @@ -120,8 +122,29 @@ ansible.builtin.lineinfile: path: "/etc/snmp/snmpd.conf" line: "extend osupdate /etc/snmp/osupdate" + - name: set ExecStart options in service file - ubuntu + ansible.builtin.lineinfile: + path: "/lib/systemd/system/snmpd.service" + regexp: '^ExecStart=' + line: "ExecStart=/usr/sbin/snmpd -LS4d -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -f" + backrefs: yes + when: ansible_os_family == "Debian" + - name: reload systemd configs - ubuntu + ansible.builtin.systemd: + daemon_reload: yes + when: ansible_os_family == "Debian" + - name: set snmpdopts - centos + ansible.builtin.lineinfile: + path: "/etc/sysconfig/snmpd" + regexp: '^# OPTIONS=|^OPTIONS=' + line: 'OPTIONS="-LS4-6d"' + when: ansible_os_family == "RedHat" - name: enable and restart snmpd.service ansible.builtin.systemd: state: restarted enabled: yes name: snmpd + - name: verify the snmpd service is running + ansible.builtin.systemd: + state: started + name: snmpd