From 203b963c96e396b6627b0a466944fa20fd4bcabf Mon Sep 17 00:00:00 2001 From: Matthieu Pignolet Date: Fri, 27 Dec 2024 20:22:14 +0400 Subject: [PATCH] Stop the service and remove the /var/lib/snmp/snmpd.conf file before updating This fixes an issue where the generates hashes are not being re-generated on Debian. Stopping the previous service, deleting the file will cause snmpd to re-generate the /var/lib/snmp/snmpd.conf config file with the new authentication hashes. --- tasks/main.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index d20dffc..f2938dd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -20,6 +20,20 @@ - snmpd - snmpd-install +- name: stop the snmp service for editing + ansible.builtin.service: + name: snmpd + state: "stopped" + tags: + - configuration + - snmpd + - snmpd-start-stop-service + +- name: delete the old snmp /var/lib/snmp/snmpd.conf + ansible.builtin.file: + state: absent + path: /var/lib/snmp/snmpd.conf + - name: update configuration file - /etc/default/snmpd.conf ansible.builtin.template: src: etc/default/snmpd.j2