aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/postgres/tasks/main.yml
blob: 541a198d0ebd9ac8e65da33c762aa697ab9d20f7 (plain)
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
# Postgres
# https://github.com/ansible/ansible/issues/16048#issuecomment-229012509
#
- name: Install db-packages
  apt:
      name: ['postgresql', 'python-psycopg2', 'sudo']
      state: present
- name: Add db to hosts
  lineinfile:
    dest: /etc/hosts
    line: "127.0.0.1 db"
    state: present
- name: Whoami
  become: false
  command: whoami
  register: whoami
- name: Fix sudo
  lineinfile:
     dest: "/etc/sudoers"
     state: present
     line: "{{ whoami.stdout }} ALL=(postgres) NOPASSWD: ALL"
- name: Make postgres-db
  postgresql_db:
    name: nms
  become: true
  become_user: postgres
  vars:
    ansible_ssh_pipelining: true
- name: Ensure a valid postgres-user
  postgresql_user:
     db: nms
     name: nms
     password: risbrod
  become: true
  become_user: postgres
  vars:
    ansible_ssh_pipelining: true
- name: Import SQL
  shell: psql nms < /opt/gondul/ansible/roles/postgres/files/schema.sql
  become: true
  become_user: postgres
  vars:
    ansible_ssh_pipelining: true