Add postgresql role
This commit is contained in:
parent
0ba65cbe05
commit
c42a3e5610
9
postgresql/defaults/main.yml
Normal file
9
postgresql/defaults/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
# Used to create specific Munin graphs.
|
||||||
|
databases: ['titi', 'toto']
|
||||||
|
|
||||||
|
# Tuning
|
||||||
|
shared_buffers: 4GB
|
||||||
|
work_mem: 8MB
|
||||||
|
random_page_cost: 1.5
|
||||||
|
effective_cache_size: 14GB
|
15
postgresql/handlers/main.yml
Normal file
15
postgresql/handlers/main.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
- name: restart munin-node
|
||||||
|
service:
|
||||||
|
name: munin-node
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: restart nagios-nrpe-server
|
||||||
|
service:
|
||||||
|
name: nagios-nrpe-server
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: restart postgresql
|
||||||
|
service:
|
||||||
|
name: postgresql
|
||||||
|
state: restarted
|
23
postgresql/tasks/config.yml
Normal file
23
postgresql/tasks/config.yml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
- name: Allow conf.d/*.conf files to be included in PostgreSQL configuration
|
||||||
|
lineinfile:
|
||||||
|
name: /etc/postgresql/9.4/main/postgresql.conf
|
||||||
|
line: include_dir = 'conf.d'
|
||||||
|
notify: restart postgresql
|
||||||
|
|
||||||
|
- name: Create conf.d directory
|
||||||
|
file:
|
||||||
|
name: /etc/postgresql/9.4/main/conf.d/
|
||||||
|
state: directory
|
||||||
|
owner: postgres
|
||||||
|
group: postgres
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Copy PostgreSQL config file
|
||||||
|
template:
|
||||||
|
src: postgresql.conf
|
||||||
|
dest: /etc/postgresql/9.4/main/conf.d/evolinux.conf
|
||||||
|
owner: postgres
|
||||||
|
group: postgres
|
||||||
|
mode: 0644
|
||||||
|
notify: restart postgresql
|
6
postgresql/tasks/main.yml
Normal file
6
postgresql/tasks/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- include: package.yml
|
||||||
|
- include: config.yml
|
||||||
|
- include: nrpe.yml
|
||||||
|
- include: munin.yml
|
23
postgresql/tasks/munin.yml
Normal file
23
postgresql/tasks/munin.yml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
- name: Add Munin plugins for PostgreSQL
|
||||||
|
file:
|
||||||
|
state: link
|
||||||
|
src: '/usr/share/munin/plugins/{{item}}'
|
||||||
|
dest: '/etc/munin/plugins/{{item}}'
|
||||||
|
with_items:
|
||||||
|
- postgres_bgwriter
|
||||||
|
- postgres_checkpoints
|
||||||
|
- postgres_connections_db
|
||||||
|
- postgres_users
|
||||||
|
- postgres_xlog
|
||||||
|
notify: restart munin-node
|
||||||
|
|
||||||
|
- name: Add Munin plugins for PostgreSQL (for specific databases)
|
||||||
|
file:
|
||||||
|
state: link
|
||||||
|
src: '/usr/share/munin/plugins/{{item[0]}}'
|
||||||
|
dest: '/etc/munin/plugins/{{item[0]}}{{item[1]}}'
|
||||||
|
with_nested:
|
||||||
|
- ['postgres_cache_', 'postgres_connections_', 'postgres_locks_', 'postgres_querylength_', 'postgres_scans_', 'postgres_size_', 'postgres_transactions_', 'postgres_tuples_']
|
||||||
|
- '{{databases}}'
|
||||||
|
notify: restart munin-node
|
20
postgresql/tasks/nrpe.yml
Normal file
20
postgresql/tasks/nrpe.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
- name: Generate random password for nrpe user
|
||||||
|
shell: apg -n1 -m 12 -M SCNL
|
||||||
|
register: nrpe_password
|
||||||
|
changed_when: False
|
||||||
|
|
||||||
|
- name: Create nrpe user
|
||||||
|
become_user: postgres
|
||||||
|
postgresql_user:
|
||||||
|
name: nrpe
|
||||||
|
password: '{{ nrpe_password.stdout }}'
|
||||||
|
no_password_changes: yes
|
||||||
|
register: create_nrpe_user
|
||||||
|
|
||||||
|
- name: Add NRPE check
|
||||||
|
lineinfile:
|
||||||
|
name: /etc/nagios/nrpe.d/evolix.cfg
|
||||||
|
line: 'command[check_pgsql]=/usr/lib/nagios/plugins/check_pgsql -H localhost -l nrpe -p "{{nrpe_password.stdout}}"'
|
||||||
|
when: create_nrpe_user.changed
|
||||||
|
notify: restart nagios-nrpe-server
|
6
postgresql/tasks/package.yml
Normal file
6
postgresql/tasks/package.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Install postgresql package
|
||||||
|
apt:
|
||||||
|
name: '{{item}}'
|
||||||
|
with_items: ['postgresql', 'ptop']
|
25
postgresql/templates/postgresql.conf
Normal file
25
postgresql/templates/postgresql.conf
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Tuning
|
||||||
|
shared_buffers = {{shared_buffers}}
|
||||||
|
work_mem = {{work_mem}}
|
||||||
|
#shared_preload_libraries = 'pg_stat_statements'
|
||||||
|
#synchronous_commit = off
|
||||||
|
checkpoint_segments = 30
|
||||||
|
checkpoint_completion_target = 0.9
|
||||||
|
random_page_cost = {{random_page_cost}}
|
||||||
|
effective_cache_size = {{effective_cache_size}}
|
||||||
|
|
||||||
|
# Loging
|
||||||
|
log_min_duration_statement = 1s
|
||||||
|
log_checkpoints = on
|
||||||
|
log_lock_waits = on
|
||||||
|
log_temp_files = 5MB
|
||||||
|
log_autovacuum_min_duration = 1s
|
||||||
|
|
||||||
|
# Locales
|
||||||
|
lc_monetary = 'fr_FR.UTF-8'
|
||||||
|
lc_numeric = 'fr_FR.UTF-8'
|
||||||
|
lc_time = 'fr_FR.UTF-8'
|
||||||
|
default_text_search_config = 'pg_catalog.french'
|
||||||
|
|
||||||
|
#escape_string_warning = off
|
||||||
|
#standard_conforming_strings = off
|
Loading…
Reference in a new issue