blob: a59faa2256df3f381d92f0aae5514c03712e9dfb (
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
|
---
- name: install postgresql
ansible.builtin.package:
name:
- postgresql-server
- postgresql-contrib
state: present
- name: install python libraries for ansible
ansible.builtin.package:
name: py3-psycopg2
state: present
- name: create postgresql data directory
ansible.builtin.file:
path: "{{ postgresql__data_dir }}"
owner: "{{ postgresql__user }}"
group: "{{ postgresql__group }}"
mode: "0700"
state: directory
- name: init postgresql database # noqa: no-changed-when
ansible.builtin.command:
argv:
- initdb
- "--pgdata={{ postgresql__data_dir }}"
- "--username={{ postgresql__db_user }}"
- --encoding=UTF-8
- --locale=en_US.UTF-8
creates: "{{ postgresql__data_dir }}/PG_VERSION"
become: true
become_user: "{{ postgresql__user }}"
- name: enable and restart postgresql service
ansible.builtin.service:
name: postgresql
state: restarted
enabled: true
|