Update to 2021-12-01 19:13

This commit is contained in:
Daniel Berteaud
2021-12-01 19:13:34 +01:00
commit 4c4556c660
2153 changed files with 60999 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
- name: Remove archive dir
file: path={{ pg_exporter_root_dir }}/archives/{{ pg_exporter_current_version }} state=absent
tags: pg

View File

@@ -0,0 +1,11 @@
---
- name: Create archive dir
file: path={{ pg_exporter_root_dir }}/archives/{{ pg_exporter_current_version }} state=directory
tags: pg
- name: Archive previous version
archive:
path: "{{ pg_exporter_root_dir }}/app"
dest: "{{ pg_exporter_root_dir }}/archives/{{ pg_exporter_current_version }}.tgz"
tags: pg

View File

@@ -0,0 +1,9 @@
---
- name: Remove tmp files
file: path={{ item }} state=absent
loop:
- "{{ pg_exporter_root_dir }}/tmp/postgres_exporter_v{{ pg_exporter_version }}_linux-amd64"
- "{{ pg_exporter_root_dir }}/tmp/postgres_exporter_v{{ pg_exporter_version }}_linux-amd64.tar.gz"
tags: pg

View File

@@ -0,0 +1,6 @@
---
- name: Deploy configuration file
template: src=postgres-exporter.conf.j2 dest={{ pg_exporter_root_dir }}/etc/postgres-exporter.conf group={{ pg_exporter_user }} mode='640'
notify: restart postgres-exporter
tags: pg

View File

@@ -0,0 +1,16 @@
---
- name: Create needed directories
file: path={{ item.dir }} state=directory owner={{ item.owner | default(omit) }} group={{ item.group | default(omit) }} mode={{ item.mode | default(omit) }}
loop:
- dir: "{{ pg_exporter_root_dir }}"
- dir: "{{ pg_exporter_root_dir }}/meta"
mode: '700'
- dir: "{{ pg_exporter_root_dir }}/archives"
mode: '700'
- dir: "{{ pg_exporter_root_dir }}/app"
- dir: "{{ pg_exporter_root_dir }}/tmp"
- dir: "{{ pg_exporter_root_dir }}/etc"
group: "{{ pg_exporter_user }}"
mode: '750'
tags: pg

View File

@@ -0,0 +1,11 @@
---
- name: Detect current version and set install mode
block:
- import_tasks: ../includes/webapps_set_install_mode.yml
vars:
root_dir: "{{ pg_exporter_root_dir }}"
version: "{{ pg_exporter_version }}"
- set_fact: pg_exporter_install_mode={{ install_mode }}
- set_fact: pg_exporter_current_version={{ current_version }}
tags: pg

View File

@@ -0,0 +1,36 @@
---
- block:
- name: Download pg_exporter
get_url:
url: "{{ pg_exporter_archive_url }}"
dest: "{{ pg_exporter_root_dir }}/tmp/"
checksum: sha1:{{ pg_exporter_archive_sha1 }}
- name: Extract pg_exporter
unarchive:
src: "{{ pg_exporter_root_dir }}/tmp/postgres_exporter_v{{ pg_exporter_version }}_linux-amd64.tar.gz"
dest: "{{ pg_exporter_root_dir }}/tmp/"
remote_src: True
- name: Move the binary to its final location
copy:
src: "{{ pg_exporter_root_dir }}/tmp/postgres_exporter_v{{ pg_exporter_version }}_linux-amd64/postgres_exporter"
dest: "{{ pg_exporter_root_dir }}/app/"
mode: '755'
remote_src: True
notify: restart postgres-exporter
when: pg_exporter_install_mode != 'none'
tags: pg
- name: Deploy systemd unit
template: src=postgres-exporter.service.j2 dest=/etc/systemd/system/postgres-exporter.service
register: pg_exporter_unit
notify: restart postgres-exporter
tags: pg
- name: Reload systemd
systemd: daemon_reload=True
when: pg_exporter_unit.changed
tags: pg

View File

@@ -0,0 +1,9 @@
---
- name: Handle postgres exporter ports in the firewall
iptables_raw:
name: postgres-exporter
state: "{{ (pg_exporter_src_ip | length > 0) | ternary('present','absent') }}"
rules: "-A INPUT -m state --state NEW -p tcp --dport {{ pg_exporter_port }} -s {{ pg_exporter_src_ip | join(',') }} -j ACCEPT"
when: iptables_manage | default(True)
tags: firewall,pg

View File

@@ -0,0 +1,15 @@
---
- include: directories.yml
- include: facts.yml
- include: archive_pre.yml
when: pg_exporter_install_mode == 'upgrade'
- include: install.yml
- include: conf.yml
- include: iptables.yml
when: iptables_manage | default(True)
- include: service.yml
- include: archive_post.yml
when: pg_exporter_install_mode == 'upgrade'
- include: write_version.yml
- include: cleanup.yml

View File

@@ -0,0 +1,5 @@
---
- name: Start and enable the service
service: name=postgres-exporter state=started enabled=True
tags: pg

View File

@@ -0,0 +1,5 @@
---
- name: Write installed version
copy: content={{ pg_exporter_version }} dest={{ pg_exporter_root_dir }}/meta/ansible_version
tags: pg