2022-09-22 14:38:42 +00:00
|
|
|
---
|
|
|
|
- name: Download snmp_exporter binary to local folder
|
|
|
|
become: false
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.get_url:
|
2022-11-25 13:53:37 +00:00
|
|
|
url: "https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/
|
|
|
|
snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
|
2022-09-22 14:38:42 +00:00
|
|
|
dest: "/tmp"
|
|
|
|
checksum: "sha256:{{ snmp_exporter_checksum }}"
|
2022-11-25 13:53:37 +00:00
|
|
|
mode: 0644
|
2022-09-22 14:38:42 +00:00
|
|
|
register: _download_binary
|
|
|
|
until: _download_binary is success
|
|
|
|
retries: 5
|
|
|
|
delay: 2
|
|
|
|
delegate_to: localhost
|
|
|
|
check_mode: false
|
|
|
|
|
|
|
|
- name: Unpack snmp_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/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
|
|
|
|
dest: "/tmp"
|
|
|
|
creates: "/tmp/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/snmp_exporter"
|
|
|
|
delegate_to: localhost
|
|
|
|
check_mode: false
|
|
|
|
|
|
|
|
- name: Propagate SNMP Exporter binaries
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.copy:
|
2022-09-22 14:38:42 +00:00
|
|
|
src: "/tmp/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/snmp_exporter"
|
|
|
|
dest: "/usr/local/bin/snmp_exporter"
|
|
|
|
mode: 0755
|
|
|
|
notify:
|
|
|
|
- restart snmp exporter
|
|
|
|
|
|
|
|
- name: Create configuration directory
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.file:
|
2022-09-22 14:38:42 +00:00
|
|
|
path: "/etc/snmp_exporter"
|
|
|
|
state: directory
|
|
|
|
owner: root
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.group: root
|
2022-09-22 14:38:42 +00:00
|
|
|
mode: 0755
|