Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Last active July 7, 2021 13:10
Show Gist options
  • Save YumaInaura/06e080e3f807338c122837bdb2d34571 to your computer and use it in GitHub Desktop.
Save YumaInaura/06e080e3f807338c122837bdb2d34571 to your computer and use it in GitHub Desktop.
Ansible—How to pass multiple module arguments ( parameters, MODULE_ARGS ) to ansible command and represent playbook?

Ansible—How to pass multiple module arguments ( parameters, MODULE_ARGS ) to ansible command and represent playbook?

Answer

Describe key=value pari separated with spaces.

$ ansible -m "[module_name]" --args="key1=value2 key2=value2"

In playbook

$ ansible localhost -m 'file' --args="path=example.txt state=touch"

Above ansible command's means bellow in playbook.

- hosts: localhost
  tasks:
    - file:
        path: example.txt
        state: touch

Versions

  • ansible 2.6.0

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment