initial ansible code

This commit is contained in:
Oli
2022-10-09 21:41:56 +00:00
parent 4a64eab4a0
commit feaec34dd2
103 changed files with 4473 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
---
- name: Get latest postgres_exporter version
github_release:
user: prometheus-community
repo: postgres_exporter
action: latest_release
token: "{{ vault_github_token }}"
delegate_to: localhost
run_once: true
register: postgres_exporter_version
- name: "{{ postgres_exporter_version }}"
set_fact:
postgres_exporter_version: "{{ postgres_exporter_version | replace ('v', '', 1) | trim }}"
run_once: true
- name: download postgres_exporter {{ postgres_exporter_version.tag }} from GitHub
get_url:
url: "https://github.com/prometheus-community/postgres_exporter/releases/download/\
v{{ postgres_exporter_version.tag }}/postgres_exporter-{{ postgres_exporter_version.tag }}\
.linux-{{ deb_architecture }}.tar.gz"
dest: "/tmp/postgres_exporter-{{ postgres_exporter_version.tag }}-linux-{{ deb_architecture }}.tar.gz"
register: _download_archive
until: _download_archive is succeeded
retries: 3
delay: 5
- name: unpack postgres_exporter binaries
unarchive:
src: "/tmp/postgres_exporter-{{ postgres_exporter_version.tag }}-linux-{{ deb_architecture }}.tar.gz"
dest: "/tmp"
creates: "/tmp/postgres_exporter-{{ postgres_exporter_version.tag }}.linux-{{ deb_architecture }}"
remote_src: true
- name: Copy postgres_exporter
copy:
src: "/tmp/postgres_exporter-{{ postgres_exporter_version.tag }}.linux-{{ deb_architecture }}/postgres_exporter"
dest: "{{ pgsql_exporter_install_dir }}/postgres_exporter"
remote_src: true
mode: 0755
notify: restart postgres_exporter
- name: Copy the postgres_exporter systemd service file
template:
src: postgres_exporter.service.j2
dest: /etc/systemd/system/postgres_exporter.service
owner: root
group: root
mode: 0644
notify: restart postgres_exporter