aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/postgres/tasks/main.yml
blob: 9551c4eba4594a067ce0caaedc8077a1bd02d8fb (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
- name: Install postgres packages
  apt:
    name:
      - python3-psycopg2
      - postgresql-{{ postgresql_version }}
      - postgresql-contrib-{{ postgresql_version }}
      - libpq-dev
    state: present
  tags:
    - role::postgres

- name: Check postgres is started and enabled on boot
  service:
    name: '{{ postgresql_daemon }}'
    state: started
    enabled: true
  tags:
    - role::postgres

- name: Add postgres users
  community.postgresql.postgresql_user: "{{ item }}"
  with_items: "{{ postgresql_users }}"
  become: true
  become_user: "{{ postgresql_user }}"
  tags:
    - role::postgres

- name: Add postgres databases
  community.postgresql.postgresql_db: "{{ item }}"
  with_items: "{{ postgresql_databases }}"
  become: true
  become_user: "{{ postgresql_user }}"
  tags:
    - role::postgres