From e0c16f87723d6ca319294bffb0cc0ad1f1ecf615 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 6 Jan 2025 17:44:25 +0100 Subject: [PATCH 1/3] Fix for: generates hashes are not being re-generated on Debian fixes #28 --- handlers/main.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/handlers/main.yml b/handlers/main.yml index d29c376..d5824d9 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,7 +1,14 @@ # handlers file --- -- name: restart snmpd +- name: remove persistent data file + ansible.builtin.file: + path: /var/lib/snmp/snmpd.conf + state: absent + listen: restart snmpd + +- name: restart service ansible.builtin.service: name: snmpd state: restarted + listen: restart snmpd when: service_default_state | default('started') == 'started' From 5ad1da3b238fe5a4d53fe14ac2b47a8c6a4ba201 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Tue, 7 Jan 2025 18:00:59 +0100 Subject: [PATCH 2/3] Make sure to stop the service before removing the "state file" --- handlers/main.yml | 8 +++++++- tasks/main.yml | 2 +- vars/main.yml | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index d5824d9..9bc782e 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,11 @@ # handlers file --- +- name: restart service + ansible.builtin.service: + name: "{{ snmpd_service_name }}" + state: stopped + listen: restart snmpd + - name: remove persistent data file ansible.builtin.file: path: /var/lib/snmp/snmpd.conf @@ -8,7 +14,7 @@ - name: restart service ansible.builtin.service: - name: snmpd + name: "{{ snmpd_service_name }}" state: restarted listen: restart snmpd when: service_default_state | default('started') == 'started' diff --git a/tasks/main.yml b/tasks/main.yml index 73bc9ed..11f88a0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -48,7 +48,7 @@ - name: start and enable service ansible.builtin.service: - name: snmpd + name: "{{ snmpd_service_name }}" state: "{{ service_default_state | default('started') }}" enabled: "{{ service_default_enabled | default(true) | bool }}" tags: diff --git a/vars/main.yml b/vars/main.yml index 90ad567..f251c19 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -4,3 +4,5 @@ snmpd_dependencies: - snmpd - snmp - snmp-mibs-downloader + +snmpd_service_name: snmpd From 3b86f58dea7e954205220283b0bb0f246ac15ba9 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Tue, 7 Jan 2025 18:16:19 +0100 Subject: [PATCH 3/3] Fix name --- handlers/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/main.yml b/handlers/main.yml index 9bc782e..0128bd1 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,6 +1,6 @@ # handlers file --- -- name: restart service +- name: stop service ansible.builtin.service: name: "{{ snmpd_service_name }}" state: stopped