-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #887 from mkllnk/datadog
Uninstall Datadog agent
- Loading branch information
Showing
19 changed files
with
36 additions
and
314 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
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
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
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,28 +1,14 @@ | ||
--- | ||
- name: enable nginx stub_status | ||
template: | ||
src: status.conf.j2 | ||
dest: /etc/nginx/conf.d/status.conf | ||
mode: 0644 | ||
owner: root | ||
group: 'www-data' | ||
- name: remove nginx stub_status | ||
file: | ||
path: /etc/nginx/conf.d/status.conf | ||
state: absent | ||
become: yes | ||
notify: | ||
- reload nginx | ||
- restart datadog-agent | ||
|
||
- name: add datadog agent to adm group | ||
user: | ||
name: 'dd-agent' | ||
groups: adm | ||
append: yes | ||
|
||
- name: enable datadog nginx integration | ||
template: | ||
src: dd-nginx.j2 | ||
dest: /etc/datadog-agent/conf.d/nginx.d/conf.yaml | ||
owner: 'dd-agent' | ||
group: 'dd-agent' | ||
mode: 0644 | ||
- name: remove datadog nginx integration | ||
file: | ||
path: /etc/datadog-agent/conf.d/nginx.d/conf.yaml | ||
state: absent | ||
become: true | ||
notify: restart datadog-agent |
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 |
---|---|---|
@@ -1,116 +1,32 @@ | ||
--- | ||
- name: add postgres stats configuration | ||
template: | ||
src: stats.conf.j2 | ||
dest: "{{ postgresql_config_path }}/conf.d/stats.conf" | ||
owner: postgres | ||
group: postgres | ||
mode: 0640 | ||
become: yes | ||
notify: restart postgres | ||
|
||
- name: add postgres logging configuration | ||
template: | ||
src: logging.conf.j2 | ||
dest: "{{ postgresql_config_path }}/conf.d/logging.conf" | ||
owner: postgres | ||
group: postgres | ||
mode: 0640 | ||
- name: remove postgres stats configuration | ||
file: | ||
path: "{{ postgresql_config_path }}/conf.d/stats.conf" | ||
state: absent | ||
become: yes | ||
notify: restart postgres | ||
when: enable_postgres_logging is defined | ||
|
||
- name: remove postgres logging configuration | ||
file: | ||
dest: "{{ postgresql_config_path }}/conf.d/logging.conf" | ||
state: absent | ||
become: yes | ||
notify: restart postgres | ||
when: enable_postgres_logging is undefined | ||
|
||
- name: get relations in openfoodnetwork's database | ||
command: "psql {{ db }} -tAc \"SELECT c.relname AS table_name | ||
FROM pg_catalog.pg_class c | ||
LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) | ||
WHERE c.relkind IN ('r','v','m','p') | ||
AND c.relpersistence <> 't' | ||
AND c.relname NOT IN ('pg_stat_statements') | ||
AND n.nspname NOT IN ('pg_catalog','pg_toast','information_schema');\"" | ||
become: yes | ||
become_user: postgres | ||
register: openfoodnetwork_relations | ||
changed_when: False | ||
|
||
- name: enable datadog postgres integration | ||
template: | ||
src: dd-postgres.j2 | ||
- name: remove datadog postgres integration | ||
file: | ||
dest: /etc/datadog-agent/conf.d/postgres.d/conf.yaml | ||
owner: 'dd-agent' | ||
group: 'dd-agent' | ||
mode: 0644 | ||
state: absent | ||
become: true | ||
when: datadog_db_password is defined | ||
notify: restart datadog-agent | ||
|
||
- name: add datadog agent to postgres group | ||
user: | ||
name: 'dd-agent' | ||
groups: postgres | ||
append: yes | ||
when: datadog_db_password is defined and enable_datadog_logging is defined | ||
|
||
- name: check datadog db_integration exists | ||
command: psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='datadog'" | ||
become: yes | ||
become_user: postgres | ||
register: integration_exists | ||
changed_when: False | ||
|
||
- name: report db_integration status | ||
fail: | ||
msg: "The database role `datadog` has not been created. Add it via the `db_integrations` playbook." | ||
when: integration_exists.stdout != '1' | ||
|
||
- name: check pg_stat_activity function | ||
command: "psql {{ db }} -c \"SELECT * FROM pg_catalog.pg_proc WHERE proname = 'pg_stat_activity';\"" | ||
become: yes | ||
become_user: postgres | ||
register: pg_stat_activity_exist | ||
changed_when: False | ||
|
||
- name: add pg_stat_activity function | ||
command: "psql {{ db }} -c \ | ||
'CREATE FUNCTION pg_stat_activity() RETURNS SETOF pg_catalog.pg_stat_activity AS $$ | ||
SELECT * from pg_catalog.pg_stat_activity; | ||
$$ LANGUAGE sql VOLATILE SECURITY DEFINER;'" | ||
become: yes | ||
become_user: postgres | ||
when: pg_stat_activity_exist.stdout.find('0 rows') != -1 | ||
notify: restart postgres | ||
|
||
- name: check pg_stat_activity_dd view | ||
command: "psql {{ db }} -c \"SELECT * FROM pg_catalog.pg_views WHERE viewname = 'pg_stat_activity_dd';\"" | ||
become: yes | ||
become_user: postgres | ||
register: pg_stat_activity_dd_exist | ||
changed_when: False | ||
|
||
- name: add pg_stat_activity_dd view | ||
command: "psql {{ db }} -c 'CREATE VIEW pg_stat_activity_dd AS SELECT * FROM pg_stat_activity();'" | ||
- name: remove pg_stat_activity_dd view | ||
command: "psql {{ db }} -c 'DROP VIEW IF EXISTS pg_stat_activity_dd;'" | ||
become: yes | ||
become_user: postgres | ||
when: pg_stat_activity_dd_exist.stdout.find('0 rows') != -1 | ||
notify: restart postgres | ||
|
||
- name: grant SELECT on pg_stat_activity_dd to Datadog | ||
postgresql_privs: | ||
database: "{{ db }}" | ||
state: present | ||
privs: SELECT | ||
type: table | ||
objs: pg_stat_activity_dd | ||
roles: datadog | ||
grant_option: no | ||
- name: remove pg_stat_activity function | ||
command: "psql {{ db }} -c 'DROP FUNCTION IF EXISTS pg_stat_activity();'" | ||
become: yes | ||
become_user: postgres | ||
notify: restart postgres |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.