aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--defaults/main.yml6
-rw-r--r--tasks/main.yml28
2 files changed, 29 insertions, 5 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index 159b40b..910d691 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,4 +1,4 @@
-# postgres_pgpass: |
-# # hostname:port:database:username:password
-# *:*:*:postgres:my super secret password
+# Do note that this role does not set the password for you.
+
+# postgres_passwd: my super secret password
diff --git a/tasks/main.yml b/tasks/main.yml
index dd3dd98..cf8d734 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -28,7 +28,31 @@
follow: false
- name: Write pgpass for 'root'
copy:
- content: '{{postgres_pgpass}}'
+ content: |
+ # hostname:port:database:username:password
+ *:*:*:postgres:{{postgres_passwd}}
dest: '/root/.pgpass'
mode: '0600'
- when: postgres_pgpass is defined
+ when: postgres_passwd is defined
+- name: Check if Netdata is installed
+ stat:
+ path: /opt/netdata
+ register: nd
+- name: Write postgres configuration for Netdata
+ copy:
+ content: |
+ socket:
+ name: 'local'
+ user: 'postgres'
+ database: 'postgres'
+ {% if postgres_passwd is defined %}password: {{postgres_passwd}}
+ {% endif %}
+ mode: '0600'
+ dest: /opt/netdata/etc/netdata/python.d/postgres.conf
+ owner: 'netdata'
+ when: nd is defined and nd.stat.exists
+- name: Install the required python modules
+ apk:
+ name: py3-psycopg2
+ state: present
+ when: nd is defined and nd.stat.exists