Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible: allow running playbook in check mode #2682

Merged
merged 1 commit into from
Jun 24, 2021

Conversation

richardlau
Copy link
Member

In some places we use the Ansible raw task to execute a command on
the remote machine. Typically this is done to check for the presence
of a file. Ansible itself has no way of knowing if the command we are
executing makes modifications to the system so does not run raw tasks
when ansible-playbook is run with --check. Some of our subsequent
tasks rely on the raw task having previous run (to create a variable)
so the playbook currently errors with messages such as:
'dict object' has no attribute ...
when run in --check mode.

Mark raw tasks that do not make modifications with check_mode: no
(which means "don't check if --check was set and just execute the
command"). This allows us to run the playbook with --check first to
see what Ansible thinks would change without actually making the
changes.

In some places we use the Ansible `raw` task to execute a command on
the remote machine. Typically this is done to check for the presence
of a file. Ansible itself has no way of knowing if the command we are
executing makes modifications to the system so does not run `raw` tasks
when `ansible-playbook` is run with `--check`. Some of our subsequent
tasks rely on the `raw` task having previous run (to create a variable)
so the playbook currently errors with messages such as:
`'dict object' has no attribute ...`
when run in `--check` mode.

Mark `raw` tasks that do not make modifications with `check_mode: no`
(which means "don't check if `--check` was set and just execute the
command"). This allows us to run the playbook with `--check` first to
see what Ansible thinks would change without actually making the
changes.
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 ok, I didn't know about this feature but trust you know what you're doing!

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@richardlau richardlau merged commit 6c5eedc into nodejs:master Jun 24, 2021
@richardlau richardlau deleted the checkmode branch June 24, 2021 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants