ansible 2.2.0.0
config file =
configured module search path = Default w/o overrides
If you attempt to validate changes to a /etc/sudoers file - even if it is a sudoers.ansible, etc it will fail if you attempt to validate or run via command visudo -q -c -f /etc/sudoers.ansible with no stdout
basic check command
- name: Final sudoers file check before copying tmp back
become: yes
command: 'visudo -q -cf /etc/sudoers.ansible'
register: checkok
it also fails if you attempt to run as a validate from lineinfile or blockinfile like
validate: 'visudo -q -c -f %s'
Expected to pass and register as 'ok'
TASK [Final sudoers file check before copying tmp back] ************************
task path: /Users/<snip>/provision_lab.yml:143
Using module file /Library/Python/2.7/site-packages/ansible/modules/core/commands/command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: <snip>
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1491238255.64-78253062874287 `" && echo ansible-tmp-1491238255.64-78253062874287="` echo $HOME/.ansible/tmp/ansible-tmp-1491238255.64-78253062874287 `" ) && sleep 0'
<127.0.0.1> PUT /var/folders/sj/zdn5tb0d51q_20z4gm0myg700000gn/T/tmpqDb6kH TO /Users/<snip>/.ansible/tmp/ansible-tmp-1491238255.64-78253062874287/command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/<snip>/.ansible/tmp/ansible-tmp-1491238255.64-78253062874287/ /Users/<snip>/.ansible/tmp/ansible-tmp-1491238255.64-78253062874287/command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -p "[sudo via ansible, key=wtmauitocwoynsgcjeydluockganqqnp] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-wtmauitocwoynsgcjeydluockganqqnp; /usr/bin/python /Users/<snip>/.ansible/tmp/ansible-tmp-1491238255.64-78253062874287/command.py; rm -rf "/Users/<snip>/.ansible/tmp/ansible-tmp-1491238255.64-78253062874287/" > /dev/null 2>&1'"'"' && sleep 0'
fatal: [localhost]: FAILED! => {
"changed": true,
"cmd": [
"visudo",
"-q",
"-cf",
"/etc/sudoers.ansible"
],
"delta": "0:00:00.008161",
"end": "2017-04-03 17:50:55.807571",
"failed": true,
"invocation": {
"module_args": {
"_raw_params": "visudo -q -cf /etc/sudoers.ansible",
"_uses_shell": false,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": true
},
"module_name": "command"
},
"rc": 1,
"start": "2017-04-03 17:50:55.799410",
"stderr": "",
"stdout": "",
"stdout_lines": [],
"warnings": []
}
TASK [Final sudoers file check before copying tmp back] ************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "visudo -q -c -f /etc/sudoers.ansible", "delta": "0:00:00.018836", "end": "2017-04-03 17:12:29.915562", "failed": true, "rc": 1, "start": "2017-04-03 17:12:29.896726", "stderr": "", "stdout": "", "stdout_lines": [], "warnings": []}