2024-04-16 20:06:17 +02:00
|
|
|
---
|
|
|
|
- name: backup docker volume
|
|
|
|
hosts: all
|
|
|
|
become: true
|
|
|
|
gather_facts: true
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
|
|
|
|
- name: make backup folder
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "/docker_backup/"
|
|
|
|
owner: "ansibleuser"
|
|
|
|
group: "ansibleuser"
|
|
|
|
mode: '0700'
|
|
|
|
state: "directory"
|
|
|
|
|
|
|
|
- name: delete old file
|
|
|
|
ansible.builtin.file:
|
2024-04-18 17:19:46 +02:00
|
|
|
path: "/docker_backup/dns_{{ ansible_hostname }}.tgz"
|
2024-04-16 20:06:17 +02:00
|
|
|
state: "absent"
|
|
|
|
|
|
|
|
- name: create archive
|
|
|
|
community.general.archive:
|
2024-04-18 17:19:46 +02:00
|
|
|
dest: "/docker_backup/dns_{{ ansible_hostname }}.tgz"
|
2024-04-16 20:06:17 +02:00
|
|
|
path: "/var/lib/docker/volumes"
|
|
|
|
owner: "ansibleuser"
|
|
|
|
|
|
|
|
- name: create sudo permision
|
|
|
|
lineinfile:
|
|
|
|
path: "/etc/sudoers.d/root"
|
|
|
|
create: true
|
|
|
|
state: present
|
|
|
|
line: "root ALL=(ansibleuser) NOPASSWD: ALL"
|
|
|
|
|
|
|
|
- name: scp file into safety
|
2024-04-18 17:19:46 +02:00
|
|
|
ansible.builtin.shell: 'scp -o "StrictHostKeyChecking accept-new" /docker_backup/dns_{{ ansible_hostname }}.tgz ansibleuser@10.10.0.2:/home/backup_ansible/'
|
2024-04-16 20:06:17 +02:00
|
|
|
become: false
|
|
|
|
|