Ansible 1.8 ansible_check_mode

Hi,

Some remote modules doesn’t support check_mode, which means they break every time I use them on some role. I saw [1] that the variable ansible_check_mode is only available on ansible 1.9, but we are still using 1.8. Is there any way of skipping the task when in check mode on this version?

The problem is, one task register a variable and the other tries to access its attribute, which fails because it is not defined. I tried to use ec2_volume.skipped check, but it stills tries to access some its attribute and fail the check.

ec2_volume": {
“changed”: false,
“invocation”: {
“module_args”: “”,
“module_name”: “ec2_vol”
},
“msg”: “remote module does not support check mode”,
“skipped”: true
}

Thanks,

– Anderson

If the first task does not harm (e.g. just look up a file or list a
directory) then set it to 'always_run: yes'. So the task is executed
even in check mode, and thus the variable is correctly registered.

Unfortunately that won't work if the task uses a file that a previous
task would create, were it not in check mode...

Johannes

Hi,

Thanks for the tip. The first task is harmful, as it creates an EBS volume in AWS. I tricked ansible creating a fact when thevar.skipped is defined, adding the pending attribute to it and then following on check mode. If the variable is registered (not on check mode), then the fact will not be set.

-- anderson