first commit

This commit is contained in:
ace 2023-08-10 17:14:07 +03:00
commit f332f22f1a
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
8 changed files with 110 additions and 0 deletions

0
README.md Normal file
View File

2
defaults/main.yaml Normal file
View File

@ -0,0 +1,2 @@
postgres_exporter_version: "0.12.0"
postgres_exporter_install_official_repo: true

8
meta/main.yaml Normal file
View File

@ -0,0 +1,8 @@
---
galaxy_info:
description: postgres_exporter
galaxy_tags:
- postgres
- exporter
dependencies: []

36
tasks/Debian.yaml Normal file
View File

@ -0,0 +1,36 @@
---
- name: Install apt-transport-https
apt:
name: apt-transport-https
state: present
- name: Add gpg keys for prometheus repo
ansible.builtin.apt_key:
url: "{{ item.url }}"
keyring: "{{ item.keyring }}"
loop: "{{ postgres_exporter_apt_key }}"
when:
- postgres_exporter_apt_key is defined
- postgres_exporter_install_official_repo
- name: Add prometheus repository
ansible.builtin.apt_repository:
repo: "{{ item.repo }}"
state: present
filename: "{{ item.filename }}"
update_cache: no
loop: "{{ postgres_exporter_apt_repository }}"
when: postgres_exporter_install_official_repo
- name: Ensure {{ postgres_exporter_package }} version {{ postgres_exporter_version }} installed
apt:
name: "{{ postgres_exporter_package }}"
state: present
- name: Enable and start {{ postgres_exporter_unit_name }}
systemd:
name: "{{ postgres_exporter_unit_name }}"
state: started
enabled: yes
masked: no
daemon_reload: yes

25
tasks/RedHat.yaml Normal file
View File

@ -0,0 +1,25 @@
---
- name: Install prometheus repository
ansible.builtin.yum_repository:
name: "{{ item.name }}"
description: "{{ item.description }}"
file: "{{ item.file }}"
baseurl: "{{ item.baseurl }}"
gpgcheck: "{{ item.gpgcheck | default('no') }}"
enabled: "{{ item.enabled | default('yes') }}"
repo_gpgcheck: "{{ item.repo_gpgcheck | default('no') }}"
gpgkey: "{{ item.gpgkey | default('omit') }}"
loop: "{{ postgres_exporter_rpm_repository }}"
- name: Ensure {{ postgres_exporter_package }} version {{ postgres_exporter_version }} installed
dnf:
name: "{{ postgres_exporter_package }}"
state: present
- name: Enable and start {{ postgres_exporter_unit_name }}
systemd:
name: "{{ postgres_exporter_unit_name }}"
state: started
enabled: yes
masked: no
daemon_reload: yes

17
tasks/main.yaml Normal file
View File

@ -0,0 +1,17 @@
---
- name: Load a variable file based on the OS type
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
- "{{ ansible_facts['os_family'] }}.yaml"
paths:
- "vars"
tags: postgres_exporter_vars
- name: Include postgres_exporter install
include_tasks: "{{ ansible_facts['os_family'] }}.yaml"

8
vars/Debian.yaml Normal file
View File

@ -0,0 +1,8 @@
postgres_exporter_apt_repository:
- repo: deb [trusted=yes] https://mirror.0xace.cc/debian/custom/ default all
filename: mirror.0xace.cc
postgres_exporter_package_name: "postgres-exporter"
postgres_exporter_package: "{{ postgres_exporter_package_name }}={{ postgres_exporter_version }}-{{ postgres_exporter_version_build }}"
postgres_exporter_version_build: "1"
postgres_exporter_unit_name: "postgres_exporter"

14
vars/RedHat.yaml Normal file
View File

@ -0,0 +1,14 @@
postgres_exporter_rpm_repository:
- name: "prometheus"
file: "prometheus"
description: "Prometheus repository"
baseurl: "https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch"
repo_gpgcheck: yes
gpgcheck: yes
gpgkey: >-
https://packagecloud.io/prometheus-rpm/release/gpgkey
https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm
postgres_exporter_package_name: "postgres_exporter"
postgres_exporter_package: "{{ postgres_exporter_package_name }}-{{ postgres_exporter_version }}"
postgres_exporter_unit_name: "{{ postgres_exporter_package_name }}"