Hi all,

Trying to use the 'find' module to collect a list of files that I will then 
operate on. To test this out, I wrote a simple playbook as follows:

- name: test playbook
  #remote_user: root
  hosts: localhost

  tasks:

  - name: find all vbox SysV init scripts in /etc/rc[0-6].d
    find:
      paths: "{{ item }}"
      patterns: "^.*virtualbox$"
      use_regex: True
    with_items:
      - /etc/rc0.d
      - /etc/rc1.d
      - /etc/rc2.d
      - /etc/rc3.d
      - /etc/rc4.d
      - /etc/rc5.d
      - /etc/rc6.d
    register: vbox_sysv_scripts

  - debug: var=vbox_sysv_scripts verbosity=2

  - name: Show me the files!
    command: ls -l {{ item.path }}
    with_items: vbox_sysv_scripts.files

However, when I run the playbook, I get an error on the "Show me the 
files!" task, which uses the result of the find registered var:

bash-4.3$ ansible-playbook -i inventory/testing -k test-find.yml 
SSH password: 

PLAY [test playbook] 
***********************************************************

TASK [setup] 
*******************************************************************
ok: [localhost]

TASK [find all vbox SysV init scripts in /etc/rc[0-6].d] 
***********************
ok: [localhost] => (item=/etc/rc0.d)
ok: [localhost] => (item=/etc/rc1.d)
ok: [localhost] => (item=/etc/rc2.d)
ok: [localhost] => (item=/etc/rc3.d)
ok: [localhost] => (item=/etc/rc4.d)
ok: [localhost] => (item=/etc/rc5.d)
ok: [localhost] => (item=/etc/rc6.d)

TASK [debug] 
*******************************************************************
skipping: [localhost]

TASK [Show me the files!] 
******************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' 
has an invalid value, which appears to include a variable that is 
undefined. The error was: 'unicode object' has no attribute 'path'\n\nThe 
error appears to have been in 
'/home/istgroup/Documents/ansible-stuff/test-find.yml': line 24, column 5, 
but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n\n  - name: Show me the 
files!\n    ^ here\n"}

If I print the "vbox_sysv_scripts" var via the debug statement, I get the 
following: 
https://gist.githubusercontent.com/wdennis/13197fe430a66da28b03de809474c294/raw/ae9d77ddc64bc3c3f55f46e0a7469bb5d1848de6/vbox_sysv_scripts

Can someone tell me where I'm going wrong here?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fc719c01-c2ef-439e-bce2-3e1f30818d9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to