force --check

54 views
Skip to first unread message

Mike Biancaniello

unread,
Feb 18, 2016, 10:12:07 AM2/18/16
to Ansible Project
Is there a compliment to the `always_run: true` option for a play?

I have a need for a playbook to always run a single task in check_mode and use the results to do something.
I really don't want to have to always run the playbook with `--check` (and use `always_run: true` for the other tasks) because if I forget to add that option, then I'll accidentally run the task I don't want to actually run.

suggestions?

Brian Coca

unread,
Feb 18, 2016, 10:28:40 AM2/18/16
to ansible...@googlegroups.com
there is a PR (not a feature yet) to set ansible_check_mode variable so you can figure out if you are in check mode or not and make your execution conditional on it.


----------
Brian Coca

Mike Biancaniello

unread,
Feb 25, 2016, 5:05:51 PM2/25/16
to Ansible Project
That might be what I'm looking for, but I'm not sure.

I want to be able to run a playbook (*not* in check_mode), but tell one task to run *only* in check_mode.

Currently, if you run in check_mode, setting `always_run: true` on a task makes that task run as if it is not in check_mode. I want the opposite of this.

I want to be able to run:
ansible-playbook stuff.yml

stuff.yml
---
- name: stuff
  hosts
: things

  tasks
:
 
- name: Apply awesome sauce
    awesome
: a=b c=d
 
- name: pretend to do something
    something
: a=b c=d
    check_mode
: true




Reply all
Reply to author
Forward
0 new messages