From ddda8e13b0fa08609f2d4e55790c3e83df49e082 Mon Sep 17 00:00:00 2001 From: Mark Janssen -- Sig-I/O Automatisering Date: Thu, 11 Jul 2024 21:45:45 +0200 Subject: [PATCH 1/3] Single task for node-exporter --- roles/common/tasks/node-exporter.yaml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/roles/common/tasks/node-exporter.yaml b/roles/common/tasks/node-exporter.yaml index 675e33c..4bd84ea 100644 --- a/roles/common/tasks/node-exporter.yaml +++ b/roles/common/tasks/node-exporter.yaml @@ -1,14 +1,7 @@ --- -- name: Install node-exporter +- name: Install or remove prometheus node-exporter ansible.builtin.apt: name: prometheus-node-exporter - state: present - when: node_exporter - -- name: Remove node-exporter - ansible.builtin.apt: - name: prometheus-node-exporter - state: absent + state: "{% if node_exporter|bool %}present{% else %}absent{% endif %} autoremove: yes - when: not node_exporter From 7d268140db55874872b9fdc4fe86e2f548c37a43 Mon Sep 17 00:00:00 2001 From: Mark Janssen -- Sig-I/O Automatisering Date: Thu, 11 Jul 2024 22:01:56 +0200 Subject: [PATCH 2/3] Integrate apt-minimal into apt.conf template --- roles/common/tasks/apt-minimal.yaml | 9 --------- roles/common/templates/apt-minimal | 4 ---- roles/common/templates/apt.conf.j2 | 3 +++ 3 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 roles/common/tasks/apt-minimal.yaml delete mode 100644 roles/common/templates/apt-minimal diff --git a/roles/common/tasks/apt-minimal.yaml b/roles/common/tasks/apt-minimal.yaml deleted file mode 100644 index 5fbbaa0..0000000 --- a/roles/common/tasks/apt-minimal.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- name: Configure auto-upgrades - ansible.builtin.template: - src: apt-minimal - dest: /etc/apt/apt.conf.d/20minimal - owner: root - group: root - mode: 0644 diff --git a/roles/common/templates/apt-minimal b/roles/common/templates/apt-minimal deleted file mode 100644 index 452a6e6..0000000 --- a/roles/common/templates/apt-minimal +++ /dev/null @@ -1,4 +0,0 @@ -# Managed by Ansible - -APT::Install-Recommends "0"; -APT::Install-Suggests "0"; diff --git a/roles/common/templates/apt.conf.j2 b/roles/common/templates/apt.conf.j2 index 714bac0..7581cc8 100644 --- a/roles/common/templates/apt.conf.j2 +++ b/roles/common/templates/apt.conf.j2 @@ -6,3 +6,6 @@ Acquire::http::Proxy "http://{{ proxy_host }}:{{ proxy_port }}/"; # Don't download translation-files Acquire::Languages "none"; + +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; From 905affc83b9ba6d84f575b6c1b09c2b72fc0800c Mon Sep 17 00:00:00 2001 From: Mark Janssen -- Sig-I/O Automatisering Date: Thu, 11 Jul 2024 22:02:32 +0200 Subject: [PATCH 3/3] Nodeexporter single task version --- roles/common/tasks/node-exporter.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/common/tasks/node-exporter.yaml b/roles/common/tasks/node-exporter.yaml index 4bd84ea..448bae1 100644 --- a/roles/common/tasks/node-exporter.yaml +++ b/roles/common/tasks/node-exporter.yaml @@ -3,5 +3,5 @@ - name: Install or remove prometheus node-exporter ansible.builtin.apt: name: prometheus-node-exporter - state: "{% if node_exporter|bool %}present{% else %}absent{% endif %} + state: "{% if node_exporter %}present{% else %}absent{% endif %}" autoremove: yes