forked from lyw07/dbadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbarman_setup.yml
More file actions
101 lines (83 loc) · 2.77 KB
/
barman_setup.yml
File metadata and controls
101 lines (83 loc) · 2.77 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
- hosts: barman
tasks:
- name: add source repository into source list
apt_repository:
repo: deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main
state: present
filename: '/etc/apt/sources.list.d/pgdg.list'
- name: import the repository signing key
apt_key:
url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc"
state: present
- name: update the package lists
apt:
update_cache: yes
- name: Install Barman
apt:
name: barman
- name: Install postgresql
apt:
name: postgresql-9.6
- name: install repmgr
apt:
name: repmgr
force: yes
- name: install barman-cli
apt:
name: barman-cli
- name: Copy barman server configuration into /etc/barman.d
template:
src: config/barman/barman.conf
dest: /etc/barman.conf
- name: Copy database server pg 's configuration into /etc/barman.d
template:
src: config/barman/pg.j2
dest: /etc/barman.d/pg.conf
- name: Copy database server standby1 's configuration into /etc/barman.d
template:
src: config/barman/standby1.j2
dest: /etc/barman.d/standby1.conf
- name: Copy database server standby2 's configuration into /etc/barman.d
template:
src: config/barman/standby2.j2
dest: /etc/barman.d/standby2.conf
- name: install pip
command: aptitude install -y python-pip
- name: install python-pexpect
command: pip install pexpect
- name: generate ssh keys
expect:
command: ssh-keygen -t rsa
responses:
'Enter file in which to save the key \(/var/lib/barman/.ssh/id_rsa\):': "\n"
'Enter passphrase \(empty for no passphrase\):': "\n"
'Enter same passphrase again:': "\n"
become: true
become_method: sudo
become_user: barman
- name: fetch the public key of barman to store in the local box
fetch:
src: /var/lib/barman/.ssh/id_rsa.pub
dest: tmp
- name: create incoming wal directory for master server
file:
path: /var/lib/barman/{{ hostvars[groups['master'][0]]['hostname'] }}/incoming
state: directory
owner: barman
group: barman
mode: 0755
- name: create incoming wal directory for standby1 server
file:
path: /var/lib/barman/{{ hostvars[groups['standby1'][0]]['hostname'] }}/incoming
state: directory
owner: barman
group: barman
mode: 0755
- name: create incoming wal directory for standby2 server
file:
path: /var/lib/barman/{{ hostvars[groups['standby2'][0]]['hostname'] }}/incoming
state: directory
owner: barman
group: barman
mode: 0755