mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-26 05:40:18 +00:00
830e69814f
Signed-off-by: anviar <oleg.kluchkin+github@gmail.com>
69 lines
2.2 KiB
YAML
69 lines
2.2 KiB
YAML
---
|
|
- name: Create the nginx_exporter group
|
|
ansible.builtin.group:
|
|
name: "{{ nginx_exporter_system_group }}"
|
|
state: present
|
|
system: true
|
|
when: nginx_exporter_system_group not in ["root", 'www-data', 'nogroup']
|
|
|
|
- name: Create the nginx_exporter user
|
|
ansible.builtin.user:
|
|
name: "{{ nginx_exporter_system_user }}"
|
|
groups: "{{ nginx_exporter_system_group }}"
|
|
append: true
|
|
shell: /usr/sbin/nologin
|
|
system: true
|
|
create_home: false
|
|
home: /
|
|
when: nginx_exporter_system_user not in ["root", 'www-data', 'nobody']
|
|
|
|
- name: Get binary
|
|
when:
|
|
- nginx_exporter_binary_local_dir | length == 0
|
|
- not nginx_exporter_skip_install
|
|
block:
|
|
|
|
- name: Download nginx_exporter binary to local folder
|
|
become: false
|
|
ansible.builtin.get_url:
|
|
url: "{{ nginx_exporter_binary_url }}"
|
|
dest: "/tmp/nginx-prometheus-exporter_{{ nginx_exporter_version }}_linux_{{ go_arch }}.tar.gz"
|
|
checksum: "sha256:{{ __nginx_exporter_checksum }}"
|
|
mode: '0644'
|
|
register: _download_binary
|
|
until: _download_binary is succeeded
|
|
retries: 5
|
|
delay: 2
|
|
delegate_to: localhost
|
|
check_mode: false
|
|
|
|
- name: Unpack nginx_exporter binary
|
|
become: false
|
|
ansible.builtin.unarchive:
|
|
src: "/tmp/nginx-prometheus-exporter_{{ nginx_exporter_version }}_linux_{{ go_arch }}.tar.gz"
|
|
dest: "/tmp"
|
|
creates: "/tmp/nginx-prometheus-exporter"
|
|
delegate_to: localhost
|
|
check_mode: false
|
|
|
|
- name: Propagate nginx_exporter binaries
|
|
ansible.builtin.copy:
|
|
src: "/tmp/nginx-prometheus-exporter"
|
|
dest: "{{ nginx_exporter_binary_install_dir }}/nginx-prometheus-exporter"
|
|
mode: 0755
|
|
owner: root
|
|
group: root
|
|
notify: restart nginx_exporter
|
|
when: not ansible_check_mode
|
|
|
|
- name: Propagate locally distributed nginx_exporter binary
|
|
ansible.builtin.copy:
|
|
src: "{{ nginx_exporter_binary_local_dir }}/nginx-prometheus-exporter"
|
|
dest: "{{ nginx_exporter_binary_install_dir }}/nginx-prometheus-exporter"
|
|
mode: 0755
|
|
owner: root
|
|
group: root
|
|
when:
|
|
- nginx_exporter_binary_local_dir | length > 0
|
|
- not nginx_exporter_skip_install
|
|
notify: restart nginx_exporter
|