Reputation: 20202
I am using the find module in ansible to get the first file (on a remote server) that matches the pattern I have mentioned in the find module. I am getting an exception in the debug message - should I be using another mechanism to achieve this?
find: paths="/home/ubuntu/" patterns="*.deb"
register: test_build
- debug: msg={{ test_build.files.0.path }}
shell: dpkg -i {{ test_build.files.0.path }}
become: True
become_user: root
become_method: sudo
Upvotes: 0
Views: 3616
Reputation: 68519
I'm not sure what this question is about (you did not show the error message), but the playbook excerpt you included contains simple syntax errors (two tasks are squeezed into one). Fixing them makes the tasks work:
- find: paths="/home/ubuntu/" patterns="*.deb"
register: test_build
- debug: msg={{ test_build.files.0.path }}
- shell: dpkg -i {{ test_build.files.0.path }}
become: True
become_user: root
become_method: sudo
Upvotes: 1