summaryrefslogtreecommitdiffstats
path: root/roles/common/tasks/bacula.yml
blob: 35666bd209097317693c7001bfd590f8419e90e9 (plain)
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
- name: Install bacula-fd
  apt: pkg=bacula-fd

- name: Create /var/lib/bacula/tmp
  file: path=/var/lib/bacula/tmp
        state=directory
        owner=root group=root
        mode=0700

- name: Delete /etc/bacula/common_default_passwords
  file: path=/etc/bacula/common_default_passwords state=absent

# Create with:
#   echo $director-dir $(pwgen -sn 64 1) | sudo tee -a /etc/bacula/passwords-fd
- name: Ensure /etc/bacula/passwords-fd exists
  file: path=/etc/bacula/passwords-fd
        state=file
        owner=root group=root
        mode=0600

- name: Configure bacula
  template: src=etc/bacula/bacula-fd.conf.j2
            dest=/etc/bacula/bacula-fd.conf
            owner=root group=root
            mode=0644
  notify:
    - Restart bacula-fd

- name: Create /etc/bacula/ssl
  file: path=/etc/bacula/ssl
        state=directory
        owner=root group=root
        mode=0755

- name: Generate a keypair for data encryption
  command: genkeypair.sh x509
                         --pubkey=/etc/bacula/ssl/{{ inventory_hostname_short }}.pem
                         --privkey=/etc/bacula/ssl/{{ inventory_hostname_short }}.pem
                         --ou=BaculaFD --cn={{ inventory_hostname }} --dns={{ inventory_hostname }}
                         -t rsa -b 4096 -h sha512
  register: r
  changed_when: r.rc == 0
  failed_when: r.rc > 1
  notify:
    - Restart bacula-fd
  tags:
    - genkey

- name: Copy the master public key for data encryption
  copy: src=certs/bacula/data-master.pem
        dest=/etc/bacula/ssl/master.pem
        owner=root group=root
        mode=0644
  tags:
    - genkey

- name: Copy bacula-fd.service
  copy: src=lib/systemd/system/bacula-fd.service
        dest=/lib/systemd/system/bacula-fd.service
        owner=root group=root
        mode=0644
  notify:
    - systemctl daemon-reload
    - Restart bacula-fd

- meta: flush_handlers

- name: Enable bacula-fd
  service: name=bacula-fd enabled=yes

- name: Start bacula-fd
  service: name=bacula-fd state=started