diff --git a/defaults/main.yml b/defaults/main.yml index 723ffff..36ec331 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,7 @@ --- node_exporter_version: 0.18.1 node_exporter_binary_local_dir: "" +node_exporter_binary_install_dir: "/usr/local/bin" node_exporter_web_listen_address: "0.0.0.0:9100" node_exporter_system_group: "node-exp" diff --git a/tasks/install.yml b/tasks/install.yml index 7d48a6b..75af7b5 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -1,4 +1,11 @@ --- +- name: create node_exporter binary install directory + file: + path: "{{ node_exporter_binary_install_dir }}" + state: directory + owner: root + group: root + - name: Create the node_exporter group group: name: "{{ node_exporter_system_group }}" @@ -43,7 +50,7 @@ - name: Propagate node_exporter binaries copy: src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}/node_exporter" - dest: "/usr/local/bin/node_exporter" + dest: "{{ node_exporter_binary_install_dir }}/node_exporter" mode: 0755 owner: root group: root @@ -54,7 +61,7 @@ - name: propagate locally distributed node_exporter binary copy: src: "{{ node_exporter_binary_local_dir }}/node_exporter" - dest: "/usr/local/bin/node_exporter" + dest: "{{ node_exporter_binary_install_dir }}/node_exporter" mode: 0755 owner: root group: root diff --git a/tasks/preflight.yml b/tasks/preflight.yml index 5f44b01..71782fd 100644 --- a/tasks/preflight.yml +++ b/tasks/preflight.yml @@ -29,14 +29,14 @@ - name: Check if node_exporter is installed stat: - path: "/usr/local/bin/node_exporter" + path: "{{ node_exporter_binary_install_dir }}/node_exporter" register: __node_exporter_is_installed check_mode: false tags: - node_exporter_install - name: Gather currently installed node_exporter version (if any) - command: "/usr/local/bin/node_exporter --version" + command: "{{ node_exporter_binary_install_dir }}/node_exporter --version" args: warn: false changed_when: false diff --git a/templates/node_exporter.service.j2 b/templates/node_exporter.service.j2 index 8be2773..8f6cde9 100644 --- a/templates/node_exporter.service.j2 +++ b/templates/node_exporter.service.j2 @@ -9,7 +9,7 @@ StartLimitInterval=0 Type=simple User={{ node_exporter_system_user }} Group={{ node_exporter_system_group }} -ExecStart=/usr/local/bin/node_exporter \ +ExecStart={{ node_exporter_binary_install_dir }}/node_exporter \ {% for collector in node_exporter_enabled_collectors -%} {% if not collector is mapping %} --collector.{{ collector }} \