aboutsummaryrefslogtreecommitdiff
path: root/tasks/client.yml
blob: 073cea09b9022e005fdfb355b8cc07e5403f34df (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
---
- name: make the server known to the client
  lineinfile:
    line: "{{ borg_server }} ecdsa-sha2-nistp256 {{ hostvars[borg_server]['ansible_ssh_host_key_ecdsa_public'] }}"
    path: /root/.ssh/known_hosts
    create: yes

- name: create borg client repo on server
  shell: "borg init --rsh \"ssh -i /root/.ssh/borg\" --encryption=none borg@{{ borg_server }}:/srv/borg/repos/{{ inventory_hostname }}"
  when: hostvars[borg_server]['ansible_local']['borg']['repos'][inventory_hostname] is not defined

- name: reload ansible_local
  setup: filter=ansible_local
  delegate_to: "{{ borg_server }}"
  delegate_facts: True
  when: hostvars[borg_server]['ansible_local']['borg']['repos'][inventory_hostname] is not defined

- name: deploy borg backup script
  template:
    dest: /usr/local/bin/adyxax_backup.sh
    src: backup.sh.j2
    owner: root
    mode: 0500

- name: Run OS specific tasks
  include_tasks: "roles/borg/tasks/client_{{ ansible_distribution }}.yml"
...