neuro_ansible/backup_jobs/backup_cups.yaml
David Rotermund 229800bf5a Update
2024-04-19 17:10:59 +02:00

38 lines
1,002 B
YAML

---
- name: backup cups
hosts: all
become: true
gather_facts: true
tasks:
- name: make backup folder
ansible.builtin.file:
path: "/cups_backup/"
owner: "ansibleuser"
group: "ansibleuser"
mode: '0700'
state: "directory"
- name: delete old file
ansible.builtin.file:
path: "/cups_backup/cups_{{ ansible_hostname }}.tgz"
state: "absent"
- name: create archive
community.general.archive:
dest: "/cups_backup/cups_{{ ansible_hostname }}.tgz"
path: "/etc/cups"
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
ansible.builtin.shell: 'scp -o "StrictHostKeyChecking accept-new" /cups_backup/cups_{{ ansible_hostname }}.tgz ansibleuser@10.10.0.2:/home/backup_ansible/'
become: false