mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 20:03:04 +00:00
32d15d4361
Signed-off-by: Mark Tomich <tomichms@nih.gov>
71 lines
2.5 KiB
YAML
71 lines
2.5 KiB
YAML
---
|
|
- name: Create the postgres_exporter group
|
|
ansible.builtin.group:
|
|
name: "{{ postgres_exporter_system_group }}"
|
|
state: present
|
|
system: true
|
|
when: postgres_exporter_system_group not in ["root", "postgres"]
|
|
|
|
- name: Create the postgres_exporter user
|
|
ansible.builtin.user:
|
|
name: "{{ postgres_exporter_system_user }}"
|
|
groups: "{{ postgres_exporter_system_group }}"
|
|
append: true
|
|
shell: /usr/sbin/nologin
|
|
system: true
|
|
create_home: false
|
|
home: /
|
|
when: postgres_exporter_system_user not in ["root", "postgres"]
|
|
|
|
- name: Get binary
|
|
when:
|
|
- postgres_exporter_binary_local_dir | length == 0
|
|
- not postgres_exporter_skip_install
|
|
block:
|
|
|
|
- name: Download postgres_exporter binary to local folder
|
|
become: false
|
|
ansible.builtin.get_url:
|
|
url: "{{ postgres_exporter_binary_url }}"
|
|
dest: "{{ postgres_exporter_archive_path }}/postgres_exporter-{{ postgres_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
|
checksum: "sha256:{{ __postgres_exporter_checksum }}"
|
|
mode: '0644'
|
|
register: _download_binary
|
|
until: _download_binary is succeeded
|
|
retries: 5
|
|
delay: 2
|
|
delegate_to: localhost
|
|
check_mode: false
|
|
|
|
- name: Unpack postgres_exporter binary
|
|
become: false
|
|
ansible.builtin.unarchive:
|
|
src: "{{ postgres_exporter_archive_path }}/postgres_exporter-{{ postgres_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
|
dest: "{{ postgres_exporter_archive_path }}"
|
|
creates: "{{ postgres_exporter_archive_path }}/postgres_exporter-{{ postgres_exporter_version }}.linux-{{ go_arch }}/postgres_exporter"
|
|
extra_opts:
|
|
- --no-same-owner
|
|
delegate_to: localhost
|
|
check_mode: false
|
|
|
|
- name: Propagate postgres_exporter binaries
|
|
ansible.builtin.copy:
|
|
src: "{{ postgres_exporter_archive_path }}/postgres_exporter-{{ postgres_exporter_version }}.linux-{{ go_arch }}/postgres_exporter"
|
|
dest: "{{ postgres_exporter_binary_install_dir }}/postgres_exporter"
|
|
mode: '0755'
|
|
owner: root
|
|
group: root
|
|
notify: restart postgres_exporter
|
|
when: not ansible_check_mode
|
|
|
|
- name: Propagate locally distributed postgres_exporter binary
|
|
ansible.builtin.copy:
|
|
src: "{{ postgres_exporter_binary_local_dir }}/postgres_exporter"
|
|
dest: "{{ postgres_exporter_binary_install_dir }}/postgres_exporter"
|
|
mode: '0755'
|
|
owner: root
|
|
group: root
|
|
when:
|
|
- postgres_exporter_binary_local_dir | length > 0
|
|
- not postgres_exporter_skip_install
|
|
notify: restart postgres_exporter
|