Skip to content

Action plugin: how to execute module with check mode unset? #87071

@felixfontein

Description

@felixfontein

Summary

In tasks, I can add check_mode: false so that the task is executed with check mode disabled, even if the user explicitly requested check mode. This is very useful when for example using ansible.builtin.command to execute something that doesn't modify state, and the result of that call is needed for further tasks.

I'm wondering how to do that in an action plugin, where I execute a module (like ansible.builtin.command) that doesn't support check mode, but where I know that for the specific set of module args it does not modify state.

The only workaround I found was to temporarily set self._task.check_mode to False. Is this the recommended way, or is there a better way to achieve this?

Issue Type

Feature Idea

Component Name

action plugins

Additional Information

This can be very useful, for example when converting roles with quite complex logic into action plugins, which are much better suited for taking care of complex logic than roles.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis issue/PR relates to a feature request.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions