I\'m very new to Ansible
Is it possible to check if a string exists in a file using Ansible.
I want to check is a user has access to a server. this can be
If you want to fail if there is no user:
tasks:
- shell: grep username /etc/passwd
changed_when: false
By default shell module will fail if command exit code is non zero.
So it will give you ok if username is there and fails otherwise.
I use changed_when: false to prevent changed state when grepping.