ansible-collection-prometheus/roles/redis_exporter/tasks/install.yml

70 lines
2.3 KiB
YAML
Raw Normal View History

---
- 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 }}"
dest: "{{ redis_exporter_archive_path }}/redis_exporter-{{ redis_exporter_version }}.linux-{{ go_arch }}.tar.gz"
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:
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"
delegate_to: localhost
check_mode: false
- name: Propagate redis_exporter binaries
ansible.builtin.copy:
src: "{{ redis_exporter_archive_path }}/redis_exporter-v{{ redis_exporter_version }}.linux-{{ go_arch }}/redis_exporter"
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