diff --git a/hosts b/hosts index d0426d6..360a780 100644 --- a/hosts +++ b/hosts @@ -8,6 +8,7 @@ 192.168.100.2 192.168.201.2 192.168.200.163 ansible_user=ubuntu +192.168.201.3 [pi] 192.168.50.2 @@ -17,6 +18,7 @@ 192.168.199.2 192.168.90.2 192.168.100.2 +192.168.201.3 [smbclient] 192.168.50.2 @@ -32,3 +34,6 @@ [public] 192.168.201.2 + +[snmpd] +192.168.201.3 diff --git a/roles/snmpd/tasks/playbook.yaml b/roles/snmpd/tasks/playbook.yaml index 3697b48..2dd0f4f 100755 --- a/roles/snmpd/tasks/playbook.yaml +++ b/roles/snmpd/tasks/playbook.yaml @@ -11,11 +11,12 @@ - lineinfile: path: /etc/snmp/snmpd.conf state: present + backrefs: yes regexp: "{{ item.regexp }}" line: "{{ item.line }}" with_items: - - { regexp: '[\s+]rocommunity public[\s+]-V[\s+]systemonly', line: ' rocommunity public' } - - { regexp: 'agentAddress[\s+]udp:127.0.0.1:161', line: 'agentAddress udp:161' } + - { regexp: '^\s+rocommunity\s+public\s+default\s+-V\s+systemonly', line: ' rocommunity public' } + - { regexp: '^agentAddress\s+udp:127.0.0.1:161', line: 'agentAddress udp:161' } tags: configure_snmpd become: true - name: enable snmpd service and ensure it is not masked