-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.yml
84 lines (74 loc) · 2.65 KB
/
main.yml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
- name: Add key for Postgres
apt_key:
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
- name: Add Postgres repo
apt_repository:
repo: 'deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main'
filename: pgdg
- name: install packages
apt:
pkg:
- libdbd-pg-perl # for munin
- pg-activity
- postgis
- postgresql
- postgresql-contrib
- postgresql-postgis
- python3-psycopg2
- zstd # for logrotate compression
- name: Get Postgres informations
become: true
become_user: postgres
community.postgresql.postgresql_info:
port: "{{ pgport }}"
register: postgres_info
- name: create postgresql conf.d
file:
path: /etc/postgresql/{{ postgres_info.version.major }}/main/conf.d
state: directory
- name: configure postgresql
template:
dest="/etc/postgresql/{{ postgres_info.version.major }}/main/conf.d/10-ansible.conf"
src="postgresql-config"
owner=root
notify:
- reload postgresql
- name: enable postgresql configuration
lineinfile:
dest: "/etc/postgresql/{{ postgres_info.version.major }}/main/postgresql.conf"
regexp: "^.*include_dir = 'conf.d"
line: "include_dir = 'conf.d' # include files ending in '.conf' from"
notify:
- reload postgresql
- name: Logrotate config for postgresql
copy:
dest: "/etc/logrotate.d/postgresql-common"
src: "logrotate-postgres"
owner: root
- name: create systemd override for postgresql
file:
path: /etc/systemd/system/[email protected]/
state: directory
- name: add systemd override for postgresql
template:
dest: "/etc/systemd/system/[email protected]/override.conf"
src: "systemd-postgresql-override.conf"
owner: root
notify:
- systemd daemon-reload
- name: add postgres munin plugin links
file:
state: link
src: "{{ item.src }}"
dest: "/etc/munin/plugins/{{ item.dest }}"
notify:
- restart munin-node
with_items:
- {src: /usr/share/munin/plugins/postgres_autovacuum, dest: postgres_autovacuum}
- {src: /usr/share/munin/plugins/postgres_checkpoints, dest: postgres_checkpoints}
- {src: /usr/share/munin/plugins/postgres_connections_, dest: postgres_connections_ALL}
- {src: /usr/share/munin/plugins/postgres_locks_, dest: postgres_locks_ALL}
- {src: /usr/share/munin/plugins/postgres_querylength_, dest: postgres_querylength_ALL}
- {src: /usr/share/munin/plugins/postgres_size_, dest: postgres_size_ALL}
- {src: /usr/share/munin/plugins/postgres_users, dest: postgres_users}
- {src: /usr/share/munin/plugins/postgres_xlog, dest: postgres_xlog}