• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1- hosts: backupdb
2  become: yes
3  vars_files:
4    - vars/main.yml
5    - local-vars/local.yml
6  tasks:
7    - name: ensure cldrbackup group is there
8      group:
9        name: cldrbackup
10        state: present
11    - name: ensure cldrbackup user is there
12      user:
13        name: cldrbackup
14        groups:
15          - cldrbackup
16        append: yes # add to the groups, do not remove
17        state: present
18        create_home: true
19    - name: set up /home/cldrbackup/.my.cnf
20      no_log: true
21      template:
22        src: templates/mycnf.j2
23        dest: /home/cldrbackup/.my.cnf
24        owner: cldrbackup
25        group: cldrbackup
26        mode: '0640'
27    - name: set up /home/cldrbackup/.ssh/
28      file:
29        path: /home/cldrbackup/.ssh/
30        owner: cldrbackup
31        group: cldrbackup
32        mode: '0700'
33        state: directory
34    - name: set up /home/cldrbackup/.ssh/config
35      template:
36        src: templates/cldrbackup/config.j2
37        dest: /home/cldrbackup/.ssh/config.j2
38        owner: cldrbackup
39        group: cldrbackup
40        mode: '0640'
41    - name: set up /home/cldrbackup/.ssh/id_rsa
42      no_log: true
43      copy:
44        src: local-vars/cldrbackup/id_rsa
45        dest: /home/cldrbackup/.ssh/id_rsa
46        owner: cldrbackup
47        group: cldrbackup
48        mode: '0640'
49    - name: set up /home/cldrbackup/.ssh/id_rsa.pub
50      copy:
51        src: local-vars/cldrbackup/id_rsa.pub
52        dest: /home/cldrbackup/.ssh/id_rsa.pub
53        owner: cldrbackup
54        group: cldrbackup
55        mode: '0640'
56    - name: set up /home/cldrbackup/.ssh/known_hosts
57      copy:
58        src: local-vars/cldrbackup/known_hosts
59        dest: /home/cldrbackup/.ssh/known_hosts
60        owner: cldrbackup
61        group: cldrbackup
62        mode: '0640'
63    - name: set up /home/cldrbackup/backup.sh
64      template:
65        src: templates/cldrbackup/backup_sh.j2
66        dest: /home/cldrbackup/.ssh/backup.sh
67        owner: cldrbackup
68        group: cldrbackup
69        mode: '0640'
70    - name: set up daily db backup cron job
71      cron:
72        name: "backup db"
73        minute: "37"
74        hour: "7"
75        job: "sh /home/cldrbackup/backup.sh >/dev/null 2>&1"
76