From 69823f869253bc5369c8ef733f0b0a74bade1323 Mon Sep 17 00:00:00 2001 From: dommgifer Date: Thu, 20 Dec 2018 17:55:13 +0800 Subject: [PATCH] Add become for Prometheus configuration tasks This is required to support execution as a non-root user. Change-Id: I60d224407c2828d6b9f1701f7637385a25fbcced Closes-Bug: #1809233 --- ansible/roles/prometheus/tasks/config.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ansible/roles/prometheus/tasks/config.yml b/ansible/roles/prometheus/tasks/config.yml index eb1bfc210a..42d862bb76 100644 --- a/ansible/roles/prometheus/tasks/config.yml +++ b/ansible/roles/prometheus/tasks/config.yml @@ -1,18 +1,19 @@ --- - name: Ensuring config directories exist + become: true file: path: "{{ node_config_directory }}/{{ item.key }}" state: "directory" owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - become: true when: - inventory_hostname in groups[item.value.group] - item.value.enabled | bool with_dict: "{{ prometheus_services }}" - name: Copying over config.json files + become: true template: src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" @@ -25,6 +26,7 @@ - Restart {{ item.key }} container - name: Find custom prometheus alert rules files + become: true local_action: module: find path: "{{ node_custom_config }}/prometheus/" @@ -35,6 +37,7 @@ - enable_prometheus_alertmanager | bool - name: Copying over custom prometheus alert rules files + become: true vars: service: "{{ prometheus_services['prometheus-server']}}" copy: @@ -51,6 +54,7 @@ - Restart prometheus-server container - name: Copying over prometheus config file + become: true vars: service: "{{ prometheus_services['prometheus-server']}}" template: @@ -68,6 +72,7 @@ - Restart prometheus-server container - name: Copying over prometheus alertmanager config file + become: true vars: service: "{{ prometheus_services['prometheus-alertmanager']}}" template: @@ -85,6 +90,7 @@ - Restart prometheus-alertmanager container - name: Copying over my.cnf for mysqld_exporter + become: true vars: service: "{{ prometheus_services['prometheus-mysqld-exporter']}}" merge_configs: