forked from crrlcx/ansible-pganalyze-collector
-
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.
[upd] adds base logic and config template
- ubuntu 20.04 tested
- Loading branch information
Carrol Cox
committed
Jul 28, 2020
1 parent
c9b25c2
commit 407e373
Showing
7 changed files
with
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
# defaults file for ansible-pganalyze-collector | ||
dpkg_force_overwrite_configs: false | ||
|
||
pganalyze_package: pganalyze-collector | ||
pganalyze_version: latest | ||
|
||
pganalyze_user: pganalyze | ||
pganalyze_group: pganalyze | ||
|
||
pganalyze_service_state: restarted | ||
|
||
pganalyze_api_key: '' | ||
pganalize_server_api_key: '' | ||
pganalyze_db_name: '*' | ||
pganalyze_db_user: "{{ pganalyze_user }}" | ||
pganalyze_db_password: '' | ||
|
||
pganalyze_servers: | ||
- name: "{{ ansible_hostname }}" | ||
api_key: "{{ pganalize_server_api_key }}" | ||
db_name: "{{ pganalyze_db_name }}" | ||
db_username: "{{ pganalyze_db_user }}" | ||
db_password: "{{ pganalyze_db_password }}" | ||
db_host: 127.0.0.1 | ||
db_port: 5432 |
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,18 @@ | ||
--- | ||
# handlers file for ansible-pganalyze-collector | ||
- name: restart pganalyze-collector | ||
service: | ||
name: pganalyze-collector | ||
state: "{{ pganalyze_service_state }}" | ||
enabled: true | ||
notify: | ||
- test pganalyze-collector | ||
|
||
- name: test pganalyze-collector | ||
command: | | ||
pganalyze-collector --test | ||
register: pganalyze_test_result | ||
changed_when: false | ||
failed_when: | ||
- pganalyze_test_result.rc == 0 | ||
- "'Test submission successful' not in pganalyze_test_result.stderr" |
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,10 @@ | ||
--- | ||
- name: configure | create pganalyze config | ||
template: | ||
src: etc/pganalyze-collector.conf.j2 | ||
dest: /etc/pganalyze-collector.conf | ||
owner: "{{ pganalyze_user }}" | ||
group: "{{ pganalyze_group }}" | ||
mode: 0640 | ||
notify: | ||
- restart pganalyze-collector |
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,33 @@ | ||
--- | ||
- name: install | add apt key | ||
apt_key: | ||
url: 'https://packages.pganalyze.com/pganalyze_signing_key.asc' | ||
state: present | ||
register: pganalize_apt_key | ||
|
||
- name: install | add repos | ||
apt_repository: | ||
repo: "deb [arch=amd64] https://packages.pganalyze.com/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}/ stable main" | ||
state: present | ||
register: pganalize_apt_sourcelist | ||
|
||
- name: install | update package cache | ||
apt: | ||
update_cache: true | ||
when: | ||
- pganalize_apt_key.changed or pganalize_apt_sourcelist.changed | ||
|
||
- name: install | install or update packages | ||
apt: | ||
name: | ||
- "{{ pganalyze_package }}{% if pganalyze_version | bool and pganalyze_version != 'latest' %}={{ pganalyze_version }}*{% endif %}" | ||
state: latest | ||
install_recommends: true | ||
force: true | ||
force_apt_get: true | ||
dpkg_options: "{{ dpkg_force_overwrite_configs | ternary('force-confdef,force-confnew', 'force-confdef,force-confold') }}" | ||
update_cache: true | ||
cache_valid_time: 3600 | ||
environment: | ||
DEBIAN_FRONTEND: noninteractive | ||
RUNLEVEL: 1 |
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,13 @@ | ||
--- | ||
# tasks file for ansible-pganalyze-collector | ||
- include_tasks: debian.yml | ||
when: | ||
- ansible_os_family == 'Debian' | ||
tags: | ||
- always | ||
|
||
- include_tasks: configure.yml | ||
tags: | ||
- always | ||
|
||
- meta: flush_handlers |
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,29 @@ | ||
{{ ansible_managed | comment }} | ||
[pganalyze] | ||
api_key: {{ pganalyze_api_key }} | ||
|
||
{% for server in pganalyze_servers %} | ||
[{{ server.name }}] | ||
{% if server.api_key is defined %}api_key: {{ server.api_key }} | ||
{% endif %} | ||
{% if server.db_name is defined %}db_name: {{ server.db_name }} | ||
{% endif %} | ||
{% if server.db_username is defined %}db_username: {{ server.db_username }} | ||
{% endif %} | ||
{% if server.db_password is defined %}db_password: {{ server.db_password }} | ||
{% endif %} | ||
{% if server.db_host is defined %}db_host: {{ server.db_host }} | ||
{% endif %} | ||
{% if server.db_port is defined %}db_port: {{ server.db_port }} | ||
{% endif %} | ||
{% if server.aws_db_instance_id is defined %}aws_db_instance_id: {{ server.aws_db_instance_id }} | ||
{% endif %} | ||
{% if server.aws_region is defined %}aws_region: {{ server.aws_region }} | ||
{% endif %} | ||
{% if server.azure_db_server_name is defined %}azure_db_server_name: {{ server.azure_db_server_name }} | ||
{% endif %} | ||
{% if server.gcp_project_id is defined %}gcp_project_id: {{ server.gcp_project_id }} | ||
{% endif %} | ||
{% if server.gcp_cloudsql_instance_id is defined %}gcp_cloudsql_instance_id: {{ server.gcp_cloudsql_instance_id }} | ||
{% endif %} | ||
{% endfor %} |
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,2 @@ | ||
--- | ||
# vars file for ansible-pganalyze-collector |