aboutsummaryrefslogtreecommitdiff
path: root/tasks/main.yml
blob: cf8d734e795ac8a2e7e2baca2436a9e0304a81c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
- name: Install Postgres
  apk:
    name: postgresql
    update_cache: yes
- name: Install Runit service directory
  file:
    state: directory
    path: /etc/sv/postgres
    mode: '0755'
- name: Install Runit service command
  template:
    src: run.j2
    dest: /etc/sv/postgres/run
    mode: '755'
- name: Install supervise symlink
  file:
    state: link
    force: yes
    src: /run/supervise.postgres
    dest: /etc/sv/postgres/supervise
    follow: false
- name: Enable postgres service
  file:
    state: link
    force: yes
    src: /etc/sv/postgres
    dest: /var/service/postgres
    follow: false
- name: Write pgpass for 'root'
  copy:
    content: |
      # hostname:port:database:username:password
      *:*:*:postgres:{{postgres_passwd}}
    dest: '/root/.pgpass'
    mode: '0600'
  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