Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Ansible issues with locate command
What I am trying to accomplish:
Get list of commands that I want to run:
[db2inst1@db2server1 ~]$ locate db2ilist | grep instance
Execute both of the commands above
First issue is that Ansible does not seem to be playing well with the locate command:
- name: Update locate database command: /bin/updatedb - name: Gather DB2 DB2 instances command: /bin/locate 'db2ilist' | /bin/grep 'instance' register: db2ilist_output
I get a rather large list of all files that have ‘instance’ in the name somewhere. I expected to only get the 2 files listed above.
Second issue is… once I have both executables inside the db2ilist_output register, how do I loop through them to execute them?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×