Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
Add binary install directory
Browse files Browse the repository at this point in the history
Binaries are currently droped in /usr/local/bin

This commit add `node_exporter_binary_install_dir` variable where user can
change the binary destination to `/opt/bin` for example.
  • Loading branch information
guimaluf committed Jan 13, 2020
1 parent e7fecae commit e30b2aa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
11 changes: 9 additions & 2 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/node_exporter.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} \
Expand Down

0 comments on commit e30b2aa

Please sign in to comment.