ansible add multiple files to zip

[root@controller home]# cat mutiplefiles2zip.yml
---
- hosts: localhost
  become: true
  tasks:
  - name: Ansible zip multiple file example
    archive:
     path: 
     - /home/kiran/file1.txt
     - /home/kiran/file2.txt
     - /home/kiran/file3.txt
     dest: /home/kiran/zipper.zip
     format: zip


[root@controller home]# ansible-playbook mutiplefiles2zip.yml

PLAY [localhost] *************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************
ok: [localhost]

TASK [Ansible zip multiple file example] *************************************************************************************************************
changed: [localhost]

PLAY RECAP *******************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0 

[root@controller home]#


root@controller home]# cd kiran
[root@controller kiran]# ls -ltr
total 4


-rw-r--r--  1 root  root    0 Oct 18 14:59 file1.txt
-rw-r--r--  1 root  root    0 Oct 18 14:59 file2.txt
-rw-r--r--  1 root  root    0 Oct 18 14:59 file3.txt

-rw-r--r--  1 root  root  310 Oct 18 15:40 zipper.zip
[root@controller kiran]# 
[root@controller kiran]# unzip  zipper.zip 
Archive:  zipper.zip
replace file1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
  inflating: file1.txt               
  inflating: file2.txt               
  inflating: file3.txt               
[root@controller kiran]# 

Comments