Pro-Notes

2025-03-27 08:56:07
---
- name: Create archive, copy to local host and delete on remote
  hosts: all

  tasks:
    - name: Create archive
      ansible.builtin.archive:
        path: /tmp/rm/*
        format: tgz
        dest: /tmp/archive.tgz

    - name: Copy archive to remote host
      ansible.builtin.copy:
        src: /tmp/archive.tgz
        dest: /tmp/down/{{ inventory_hostname }}.tgz
        mode: '0644'

    - name: Delete archive on remote host
      ansible.builtin.file:
        path: /tmp/down/{{ inventory_hostname }}.tgz
        state: absent
← Previous Next →
Back to list