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

Commit f6f13c7

Browse files
guimalufpaulfantom
authored andcommitted
Add binary install directory (#137)
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.
1 parent 1df73df commit f6f13c7

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

tasks/install.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
---
2+
- name: create node_exporter binary install directory
3+
file:
4+
path: "{{ _node_exporter_binary_install_dir }}"
5+
state: directory
6+
owner: root
7+
group: root
8+
29
- name: Create the node_exporter group
310
group:
411
name: "{{ node_exporter_system_group }}"
@@ -43,7 +50,7 @@
4350
- name: Propagate node_exporter binaries
4451
copy:
4552
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}/node_exporter"
46-
dest: "/usr/local/bin/node_exporter"
53+
dest: "{{ _node_exporter_binary_install_dir }}/node_exporter"
4754
mode: 0755
4855
owner: root
4956
group: root
@@ -54,7 +61,7 @@
5461
- name: propagate locally distributed node_exporter binary
5562
copy:
5663
src: "{{ node_exporter_binary_local_dir }}/node_exporter"
57-
dest: "/usr/local/bin/node_exporter"
64+
dest: "{{ _node_exporter_binary_install_dir }}/node_exporter"
5865
mode: 0755
5966
owner: root
6067
group: root

tasks/preflight.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929

3030
- name: Check if node_exporter is installed
3131
stat:
32-
path: "/usr/local/bin/node_exporter"
32+
path: "{{ _node_exporter_binary_install_dir }}/node_exporter"
3333
register: __node_exporter_is_installed
3434
check_mode: false
3535
tags:
3636
- node_exporter_install
3737

3838
- name: Gather currently installed node_exporter version (if any)
39-
command: "/usr/local/bin/node_exporter --version"
39+
command: "{{ _node_exporter_binary_install_dir }}/node_exporter --version"
4040
args:
4141
warn: false
4242
changed_when: false

templates/node_exporter.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ StartLimitInterval=0
99
Type=simple
1010
User={{ node_exporter_system_user }}
1111
Group={{ node_exporter_system_group }}
12-
ExecStart=/usr/local/bin/node_exporter \
12+
ExecStart={{ _node_exporter_binary_install_dir }}/node_exporter \
1313
{% for collector in node_exporter_enabled_collectors -%}
1414
{% if not collector is mapping %}
1515
--collector.{{ collector }} \

vars/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ go_arch_map:
77
armv6l: 'armv6'
88

99
go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
10+
11+
_node_exporter_binary_install_dir: "/usr/local/bin"

0 commit comments

Comments
 (0)