Skip to content

Refactor ansible.builtin.command calls (use argv or ansible.builtin.script where reasonable) #14

@andreashaerter

Description

@andreashaerter

To quote our style guide:

You SHOULD:

  • Use the argv attribute (list) instead of cmd for ansible.builtin.command:
  • Avoids quoting issues entirely.
  • Allows comments above individual parameters.
  • Easier to build command arguments conditionally from variables.

[...]

You SHOULD:

  • Keep inline scripts short (roughly 50 lines maximum).

[...]

Reasoning:

  • A well-parameterized, linted standalone script (used with ansible.builtin.script) is a better intermediate step towards a fully-featured Ansible module than inline scripting. It encourages proper structure, parameters, testability, and can later be converted to a module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions