Files
EX407-Ansible-Automation/playbooks/backup-logs.yml
2020-03-25 16:05:01 +01:00

18 lines
444 B
YAML

---
- hosts: all
user: ansible
become: yes
gather_facts: no
tasks:
- name: Compress directory /var/log/ into /home/ansible/logs.zip
archive:
path: /var/log
dest: /home/ansible/logs.tar.gz
owner: ansible
group: ansible
format: gz
- name: Fetch the log files to the local filesystem
fetch:
src: /home/ansible/logs.tar.gz
dest: logbackup-{{ inventory_hostname }}.tar.gz
flat: yes