TASK [archive the files] fatal: : FAILED! => {"msg": "'dict object' has no attribute 'files'"}
68 views
Skip to first unread message
Nithin Subbaraj
unread,
Jan 20, 2021, 10:31:28 AM1/20/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Hi Team,
I am trying to create an ansible script which excludes a particular directory and its contents and should zip the files under other directories but getting the below error
TASK [archive the files] fatal: : FAILED! => {"msg": "'dict object' has no attribute 'files'"}
my script
################################## --- - hosts: all  tasks:   - name: exclude an intermediate directory     find:        paths: /home/nsubbaraj/toplevel        recurse: true        excludes: foo     register: result   - debug:        msg: "{{ result.files|map(attribute='path')|list }}"   - name: exclude an intermediate directory with find command     command: >-       find toplevel -name foo -prune -o -type f -mtime +7 -print     register: results   - debug:       msg: "{{ result.stdout_lines }}"   - name: archive the files     become: yes     archive:      remove: yes      path: "{{ item.path }}"      dest: "{{ item.path }}-{{ansible_date_time.date.replace('-','')}}.gz"      format: zip     with_items: "{{ results.files }}"
#############################################
PLAY [all] **********************************************************************************************************************************************************************************
TASK [exclude an intermediate directory] **************************************************************************************************************************************************** ok: [qc1udataoas01]
TASK [debug] ******************************************************************************************************************************************************************************** Â { Â Â Â "msg": [ Â Â Â Â Â Â Â "/home/nsubbaraj/toplevel/foo/testfile1.txt", Â Â Â Â Â Â Â "/home/nsubbaraj/toplevel/bar/testfile2.txt", Â Â Â Â Â Â Â "/home/nsubbaraj/toplevel/bar/testfile1", Â Â Â Â Â Â Â "/home/nsubbaraj/toplevel/bar/testfile3.gz" Â Â Â ] }
TASK [exclude an intermediate directory with find command] **********************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************** Â => { Â Â Â "msg": [ Â Â Â Â Â Â Â "toplevel/bar/testfile1", Â Â Â Â Â Â Â "toplevel/bar/testfile3.gz" Â Â Â ] }
TASK [archive the files] ******************************************************************************************************************************************************************** fatal:Â FAILED! => {"msg": "'dict object' has no attribute 'files'"}
PLAY RECAP ********************************************************************************************************************************************************************************** Â Â Â Â Â Â Â Â Â Â Â Â : ok=5Â Â Â changed=1Â Â Â unreachable=0Â Â Â failed=1Â Â Â skipped=0Â Â Â rescued=0Â Â Â ignored=0
Stefan Hornburg (Racke)
unread,
Jan 20, 2021, 10:46:38 AM1/20/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
On 1/20/21 4:31 PM, Nithin Subbaraj wrote:
> Hi Team,
>
> I am trying to create an ansible script which excludes a particular directory and its contents
> and should zip the files under other directories but getting the below error
>
> TASK [archive the files] fatal: : FAILED! => {"msg": "'dict object' has no attribute 'files'"}
>
Only the find module would add "files" to the registered value- The command module
doesn't do that.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Thanks for the help ,our main aim is to create a automated ansible script which takes multiple path (hard coded) and with find module it should check files older than 7 days and should exclude few directories or files and should compress the other files.
But somehow find and exclude path with time stamp is not working
I am trying multiple approaches but not successful but no luck ,any hint would be helpful