I’m try to use the Loop and Stat modules instead Shell command with Ansible playbook.
Whenever I run the playbook with --check, I always get the ‘Pass’ message.
The error was: error while evaluating conditional (audit_tools.stat.mode != ‘0755’): ‘dict object’ has no attribute ‘stat’\n\n
So I made a slight chance, I added "failed_when: audit_tools.stat.mode != ‘0755’’ below ‘register’ module and the error message went away.
By the way, all files are exist.
I changed two files chmod to 0640 for testing purpose.
However, I still get the ‘Passed’ as a result when I ran the --check mode.
Another issue, when all the files have proper permissions, then the playbook would give me the result as ‘Failed.’
This is the opposite of what I want.
TASK [debug] ***********************************************************************************************
ok: [localhost] => {
“msg”: “V-219195 FAILED. Audit tools aren’t configured with mode of 0755 or less permissive.”