aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2019-10-10 18:27:32 -0400
committerMitch Riedstra <mitch@riedstra.us>2019-10-10 18:27:32 -0400
commit5f97b9e837190ad432b1ddc0ac40a7c4e34619fc (patch)
treee68666dc592337d7d19ee31dc10645dd3e41351e
parent5725d926f9ef7bc750f6b09bf67b33aa3e033a6f (diff)
downloadalpine-postgres-5f97b9e837190ad432b1ddc0ac40a7c4e34619fc.tar.gz
alpine-postgres-5f97b9e837190ad432b1ddc0ac40a7c4e34619fc.tar.xz
Add support for netdata and alter how the password is pushed down to the server
-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