2022-09-22 14:38:42 +00:00
|
|
|
---
|
|
|
|
- name: Create the node_exporter group
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.group:
|
2022-09-22 14:38:42 +00:00
|
|
|
name: "{{ _node_exporter_system_group }}"
|
|
|
|
state: present
|
|
|
|
system: true
|
|
|
|
when: _node_exporter_system_group != "root"
|
|
|
|
|
|
|
|
- name: Create the node_exporter user
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.user:
|
2022-09-22 14:38:42 +00:00
|
|
|
name: "{{ _node_exporter_system_user }}"
|
|
|
|
groups: "{{ _node_exporter_system_group }}"
|
|
|
|
append: true
|
|
|
|
shell: /usr/sbin/nologin
|
|
|
|
system: true
|
|
|
|
create_home: false
|
|
|
|
home: /
|
|
|
|
when: _node_exporter_system_user != "root"
|
|
|
|
|
2022-11-25 13:53:37 +00:00
|
|
|
- name: Discover latest version
|
|
|
|
when: node_exporter_binary_local_dir | length == 0
|
|
|
|
block:
|
|
|
|
|
2022-09-22 14:38:42 +00:00
|
|
|
- name: Download node_exporter binary to local folder
|
|
|
|
become: false
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.get_url:
|
2023-02-22 17:29:16 +00:00
|
|
|
url: "{{ node_exporter_binary_url }}"
|
2022-09-22 14:38:42 +00:00
|
|
|
dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
2023-01-14 01:00:49 +00:00
|
|
|
checksum: "sha256:{{ __node_exporter_checksum }}"
|
2022-09-22 14:38:42 +00:00
|
|
|
mode: '0644'
|
|
|
|
register: _download_binary
|
|
|
|
until: _download_binary is succeeded
|
|
|
|
retries: 5
|
|
|
|
delay: 2
|
|
|
|
delegate_to: localhost
|
|
|
|
check_mode: false
|
|
|
|
|
|
|
|
- name: Unpack node_exporter binary
|
|
|
|
become: false
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.unarchive:
|
2022-09-22 14:38:42 +00:00
|
|
|
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
|
|
|
dest: "/tmp"
|
|
|
|
creates: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}/node_exporter"
|
|
|
|
delegate_to: localhost
|
|
|
|
check_mode: false
|
|
|
|
|
|
|
|
- name: Propagate node_exporter binaries
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.copy:
|
2022-09-22 14:38:42 +00:00
|
|
|
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}/node_exporter"
|
|
|
|
dest: "{{ _node_exporter_binary_install_dir }}/node_exporter"
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
2022-12-08 17:45:42 +00:00
|
|
|
group: root
|
2022-09-22 14:38:42 +00:00
|
|
|
notify: restart node_exporter
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
2022-11-25 10:37:52 +00:00
|
|
|
- name: Propagate locally distributed node_exporter binary
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.copy:
|
2022-09-22 14:38:42 +00:00
|
|
|
src: "{{ node_exporter_binary_local_dir }}/node_exporter"
|
|
|
|
dest: "{{ _node_exporter_binary_install_dir }}/node_exporter"
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
2022-12-08 17:45:42 +00:00
|
|
|
group: root
|
2022-09-22 14:38:42 +00:00
|
|
|
when: node_exporter_binary_local_dir | length > 0
|
|
|
|
notify: restart node_exporter
|