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?