-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0066d69
commit b0a5d5e
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: 'Converge' | ||
hosts: all | ||
roles: | ||
- role: antmelekhin.postgres_exporter | ||
postgres_exporter_data_source_uri: 'localhost:5432/molecule?sslmode=disable' | ||
postgres_exporter_data_source_user: 'exporter' | ||
postgres_exporter_data_source_pass: 'Passw0rd' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
role_name_check: 2 | ||
dependency: | ||
name: 'galaxy' | ||
enabled: true | ||
driver: | ||
name: 'docker' | ||
platforms: | ||
- name: 'postgres_exporter-${IMAGE:-docker-systemd}-${TAG:-ubuntu-22.04}${TOX_ENVNAME}' | ||
image: '${NAMESPACE:-antmelekhin}/${IMAGE:-docker-systemd}:${TAG:-ubuntu-22.04}' | ||
published_ports: | ||
- '0.0.0.0:9187:9187/udp' | ||
- '0.0.0.0:9187:9187/tcp' | ||
volumes: | ||
- '/sys/fs/cgroup:/sys/fs/cgroup:rw' | ||
- '/var/lib/containerd' | ||
cgroupns_mode: 'host' | ||
privileged: true | ||
pre_build_image: true | ||
provisioner: | ||
name: 'ansible' | ||
verifier: | ||
name: 'ansible' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
- name: 'Prepare an Ansible host for GitHub Actions' | ||
hosts: localhost | ||
tasks: | ||
- name: 'Install tar for tasks delegated to the localhost' | ||
community.general.apk: | ||
name: 'tar' | ||
update_cache: true | ||
when: ansible_os_family == 'Alpine' | ||
|
||
- name: 'Prepare' | ||
hosts: all | ||
vars: | ||
locale: 'en_US.UTF-8' | ||
|
||
pre_tasks: | ||
- name: 'Update APT cache' | ||
ansible.builtin.apt: | ||
update_cache: true | ||
cache_valid_time: 600 | ||
when: ansible_os_family == 'Debian' | ||
|
||
- name: 'Set database locale if using RedHat 8' | ||
ansible.builtin.set_fact: | ||
locale: 'C.UTF-8' | ||
when: | ||
- ansible_os_family == 'RedHat' and | ||
ansible_distribution_major_version == '8' | ||
|
||
roles: | ||
- role: geerlingguy.postgresql | ||
postgresql_users: | ||
- name: 'exporter' | ||
password: 'Passw0rd' | ||
role_attr_flags: 'SUPERUSER' | ||
postgresql_databases: | ||
- name: 'molecule' | ||
lc_collate: '{{ locale }}' | ||
lc_ctype: '{{ locale }}' | ||
encoding: 'UTF-8' | ||
template: 'template0' | ||
owner: 'exporter' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: 'Verify' | ||
hosts: all | ||
gather_facts: false | ||
|
||
tasks: | ||
- name: 'Gathering Service Facts' | ||
ansible.builtin.service_facts: | ||
|
||
- name: 'Assert that Postgres Exporter service is enabled and running' | ||
ansible.builtin.assert: | ||
that: | ||
- ansible_facts.services['postgres_exporter.service'].state == 'running' | ||
- ansible_facts.services['postgres_exporter.service'].status == 'enabled' | ||
|
||
- name: 'Verify the Postgres Exporter is responding to requests' | ||
ansible.builtin.uri: | ||
url: 'http://{{ ansible_host }}:9187/metrics' | ||
register: __postgres_exporter_response | ||
until: __postgres_exporter_response.status == 200 | ||
retries: 120 | ||
delay: 5 |