From d0b59794d88108e185591832aa379744aabdf985 Mon Sep 17 00:00:00 2001 From: Yoann Date: Mon, 14 Jun 2021 12:25:20 +0200 Subject: [PATCH 1/3] Add ability to perform download and installation of apache_exporter binary on remote only --- defaults/main.yml | 3 +++ tasks/install.yml | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 101fe89..2e6323e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,6 +2,9 @@ apache_exporter_version: 0.5.0 +# Must we perform download and propagation from localhost (true) or not (false) +apache_exporter_download_localhost: false + apache_exporter_system_group: apache-exp apache_exporter_system_user: "{{ apache_exporter_system_group }}" diff --git a/tasks/install.yml b/tasks/install.yml index daee7cd..8d0b99b 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -19,19 +19,21 @@ get_url: url: "{{ apache_exporter_download_url }}" dest: "/tmp/apache_exporter-{{ apache_exporter_version }}.linux-{{ go_arch }}.tar.gz" + become: "{{ false if not apache_exporter_download_localhost is defined else omit }}" register: __download_binary until: __download_binary is succeeded retries: 5 delay: 2 - delegate_to: localhost + delegate_to: "{{ 'localhost' if apache_exporter_download_localhost else inventory_hostname }}" check_mode: false -- name: Unpack node_exporter binary +- name: Unpack apache_exporter binary unarchive: src: "/tmp/apache_exporter-{{ apache_exporter_version }}.linux-{{ go_arch }}.tar.gz" dest: "/tmp" creates: "/tmp/apache_exporter-{{ apache_exporter_version }}.linux-{{ go_arch }}/apache_exporter" - delegate_to: localhost + become: "{{ false if not apache_exporter_download_localhost else omit }}" + delegate_to: "{{ 'localhost' if apache_exporter_download_localhost else inventory_hostname }}" check_mode: false become: false @@ -48,4 +50,5 @@ mode: 0750 owner: "{{ apache_exporter_system_user }}" group: "{{ apache_exporter_system_group }}" + remote_src: "{{ false if apache_exporter_download_localhost else true }}" notify: restart apache_exporter From f90bdfd2f8d0e536a816f210d64dcf3c10a64715 Mon Sep 17 00:00:00 2001 From: Yoann Date: Mon, 14 Jun 2021 15:32:33 +0200 Subject: [PATCH 2/3] fix double declaration of become variable --- tasks/install.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tasks/install.yml b/tasks/install.yml index 8d0b99b..29f0523 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -32,9 +32,8 @@ src: "/tmp/apache_exporter-{{ apache_exporter_version }}.linux-{{ go_arch }}.tar.gz" dest: "/tmp" creates: "/tmp/apache_exporter-{{ apache_exporter_version }}.linux-{{ go_arch }}/apache_exporter" - become: "{{ false if not apache_exporter_download_localhost else omit }}" delegate_to: "{{ 'localhost' if apache_exporter_download_localhost else inventory_hostname }}" - check_mode: false + become: "{{ false if not apache_exporter_download_localhost else omit }}" become: false - name: Create local bin dir From 5eede17f138a4814473cd9a65b4a52a88eec8a3e Mon Sep 17 00:00:00 2001 From: Yoann Date: Tue, 15 Jun 2021 14:23:21 +0200 Subject: [PATCH 3/3] variable apache_exporter_download_localhost set to true to have default behaviour --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 2e6323e..8d984cf 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,7 +3,7 @@ apache_exporter_version: 0.5.0 # Must we perform download and propagation from localhost (true) or not (false) -apache_exporter_download_localhost: false +apache_exporter_download_localhost: true apache_exporter_system_group: apache-exp apache_exporter_system_user: "{{ apache_exporter_system_group }}"