-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-pbm.yml
58 lines (58 loc) · 1.75 KB
/
install-pbm.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
# Installs Percona Backup for MongoDB
# https://docs.percona.com/percona-backup-mongodb/installation.html#install-pbm-on-debian-and-ubuntu
# All nodes must have access to the backup directory
# Ubuntu Variables:
# rhel_ubuntu_dir = default
# For rhel_ubuntu_lib Ubuntu = /lib/systemd/system/pbm-agent.service
# Red Hat Variables:
# rhel_ubuntu_dir = sysconfig
# rhel_ubuntu_lib = /usr/lib/systemd/system/pbm-agent.service
- hosts: dbservers
become_user: ubuntu
become: yes
vars:
rhel_ubuntu_dir: default
rhel_ubuntu_lib: /lib/systemd/system/pbm-agent.service
pbm_user: pbm
pbm_user_pwd: 5432154321
mongodb_backup_path: /data/backups
tasks:
- name: Enable Percona Backup for MongoDB in the Percona release tool
shell: sudo percona-release enable pbm release
- name: Update all repos
shell: sudo apt update
- name: Install Percona Backup for MongoDB
shell: sudo apt install percona-backup-mongodb
- name: Copy the pbm-agent.service file using j2
template:
src: pbm-agent.service.j2
dest: "{{ rhel_ubuntu_lib }}"
owner: root
group: root
mode: 0644
- name: Copy the pbm-agent file
template:
src: pbm-agent.j2
dest: /etc/{{ rhel_ubuntu_dir }}/pbm-agent
owner: root
group: root
mode: 0640
- name: Copy the pbm_config.yaml file
template:
src: pbm_config.yaml.j2
dest: /etc/pbm_config.yaml
owner: mongod
group: mongod
mode: 0600
- name: Create backup directory
file:
path: "{{ mongodb_backup_path }}"
state: directory
owner: mongod
group: mongod
mode: 0770
- name: Enable Percona Backup
shell: sudo systemctl enable pbm-agent
- name: Start Percona Backup
shell: sudo systemctl start pbm-agent
...