diff --git a/defaults/main.yml b/defaults/main.yml index 101fe89..8d984cf 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: true + 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 f36c929..b20f2b2 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -19,11 +19,12 @@ 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 become: false @@ -32,8 +33,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" - delegate_to: localhost - check_mode: false + delegate_to: "{{ 'localhost' if apache_exporter_download_localhost else inventory_hostname }}" + become: "{{ false if not apache_exporter_download_localhost else omit }}" become: false - name: Create local bin dir @@ -49,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