Ansible 1.8 ansible_check_mode

70 views
Skip to first unread message

anderson...@boxever.com

unread,
May 31, 2016, 2:47:01 PM5/31/16
to Ansible Project
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

Johannes Kastl

unread,
May 31, 2016, 3:36:13 PM5/31/16
to ansible...@googlegroups.com
On 31.05.16 20:37 anderson...@boxever.com wrote:

> 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.

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

signature.asc

Anderson Goulart

unread,
May 31, 2016, 3:40:56 PM5/31/16
to ansible...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages