2024-02-22 13:43:10 +00:00
|
|
|
---
|
|
|
|
- name: Create the redis_exporter group
|
|
|
|
ansible.builtin.group:
|
|
|
|
name: "{{ redis_exporter_system_group }}"
|
|
|
|
state: present
|
|
|
|
system: true
|
|
|
|
when: redis_exporter_system_group != "root"
|
|
|
|
|
|
|
|
- name: Create the redis_exporter user
|
|
|
|
ansible.builtin.user:
|
|
|
|
name: "{{ redis_exporter_system_user }}"
|
|
|
|
groups: "{{ redis_exporter_system_group }}"
|
|
|
|
append: true
|
|
|
|
shell: /usr/sbin/nologin
|
|
|
|
system: true
|
|
|
|
create_home: false
|
|
|
|
home: /
|
|
|
|
when: redis_exporter_system_user != "root"
|
|
|
|
|
|
|
|
- name: Get binary
|
|
|
|
when:
|
|
|
|
- redis_exporter_binary_local_dir | length == 0
|
|
|
|
- not redis_exporter_skip_install
|
|
|
|
block:
|
|
|
|
|
|
|
|
- name: Download redis_exporter binary to local folder
|
|
|
|
become: false
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: "{{ redis_exporter_binary_url }}"
|
2024-02-29 15:55:40 +00:00
|
|
|
dest: "{{ redis_exporter_archive_path }}/redis_exporter-{{ redis_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
2024-02-22 13:43:10 +00:00
|
|
|
checksum: "sha256:{{ __redis_exporter_checksum }}"
|
|
|
|
mode: '0644'
|
|
|
|
register: _download_binary
|
|
|
|
until: _download_binary is succeeded
|
|
|
|
retries: 5
|
|
|
|
delay: 2
|
|
|
|
delegate_to: localhost
|
|
|
|
check_mode: false
|
|
|
|
|
|
|
|
- name: Unpack redis_exporter binary
|
|
|
|
become: false
|
|
|
|
ansible.builtin.unarchive:
|
2024-02-29 15:55:40 +00:00
|
|
|
src: "{{ redis_exporter_archive_path }}/redis_exporter-{{ redis_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
|
|
|
dest: "{{ redis_exporter_archive_path }}"
|
|
|
|
creates: "{{ redis_exporter_archive_path }}/redis_exporter-{{ redis_exporter_version }}.linux-{{ go_arch }}/redis_exporter"
|
2024-02-22 13:43:10 +00:00
|
|
|
delegate_to: localhost
|
|
|
|
check_mode: false
|
|
|
|
|
|
|
|
- name: Propagate redis_exporter binaries
|
|
|
|
ansible.builtin.copy:
|
2024-02-29 15:55:40 +00:00
|
|
|
src: "{{ redis_exporter_archive_path }}/redis_exporter-v{{ redis_exporter_version }}.linux-{{ go_arch }}/redis_exporter"
|
2024-02-22 13:43:10 +00:00
|
|
|
dest: "{{ redis_exporter_binary_install_dir }}/redis_exporter"
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
notify: restart redis_exporter
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: Propagate locally distributed redis_exporter binary
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ redis_exporter_binary_local_dir }}/redis_exporter"
|
|
|
|
dest: "{{ redis_exporter_binary_install_dir }}/redis_exporter"
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
when:
|
|
|
|
- redis_exporter_binary_local_dir | length > 0
|
|
|
|
- not redis_exporter_skip_install
|
|
|
|
notify: restart redis_exporter
|