ahuffman / ansible-sudoers

Controls the configuration of the default /etc/sudoers file and included files/directories.
MIT License
108 stars 45 forks source link

"--check"-mode run fails due to undefined sudoers_includes_separate_specs.stdout #21

Closed rhaamo closed 6 years ago

rhaamo commented 6 years ago

Hi,

Using --check it fails with following error:

{"msg": "The conditional check 'sudoers_includes_separate_specs.stdout != \"1\"' failed. The error was: error while evaluating conditional (sudoers_includes_separate_specs.stdout != \"1\"): 'dict object' has no attribute 'stdout'

Because shell commands are ignored when --check ing.

It looks like it's possible to use a check_mode: yes:

Force a task to run in check mode, even when the playbook is called without --check. This is called check_mode: yes.
  - name: this task will always run under checkmode and not change the system
    lineinfile: line="important config" dest=/path/to/myconfig.conf state=present
    check_mode: yes

From http://docs.ansible.com/ansible/latest/playbooks_checkmode.html#enabling-or-disabling-check-mode-for-tasks & https://stackoverflow.com/a/46454251

ahuffman commented 6 years ago

I've updated the playbook to no longer include the command that was causing you problems in check mode. That command is not necessary to the overall playbook since the lineinfile module will ensure that line is in the /etc/sudoers file if the sudoers_separate_specs boolean is enabled.

I've pushed the update, and added a new release 1.0.3 now available on Ansible Galaxy.