aboutsummaryrefslogtreecommitdiffstats
path: root/molecule/default/converge.yml
blob: 7212eb287c27c82fcdac76a0465ca5e3bd63edb2 (plain) (blame)
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
---
- name: Converge
  hosts: borg-client

  pre_tasks:
      # This would usually be set by the user globally on their ansible
      # repository and can be a security risk to do automatically. We will
      # however set the variable here in the pre_tasks since it is for testing.
    - name: Set borg server openssh key variable
      become: true
      block:
        - name: Start ssh
          ansible.builtin.systemd:
            name: sshd
            state: started
          become: true
          delegate_to: '{{ borg_server_host }}'

        - name: Fetch ssh_key
          ansible.builtin.command: >
            ssh-keyscan -t rsa
            {{ borg_server_host }}
            | sed "s/^[^ ]* //"
          register: borg_server_ssh_keyscan
          changed_when: false

        - name: Set ssh_key
          ansible.builtin.set_fact:
            borg_server_host_ssh_key: '{{ borg_server_ssh_keyscan.stdout
                                       | split(" ")
                                       | reject("search", borg_server_host)
                                       | join(" ") }}'

  vars:
    borg_server_host: borg-server
    borg_server_user_home: /opt/borg
    borg_decryption_keys_yaml_path: '{{ playbook_dir }}/decryption_keys.yml'
    borg_included_dirs:
      - /etc
      - /home
    borg_excluded_dirs:
      - /opt
      - /var
      - /reee reeee

  roles:
    - role: kliwniloc.borgbackup