Ansible - JsonArgs Module Type

> Infrastructure as code > Ansible

1 - About

JsonArgs is a module type. It's a script that contains the following placeholder <<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>> placeholder. During execution, Ansible will replace it with the module parameters.

3 - Process / Dev

  • Create a script with the placeholder <<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>>
myModuleScript.py
json_arguments = """<<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>>"""
  • Ansible will replace the placeholder with the module parameters in Json format before executing
myModuleScript.py
json_arguments = """{"param1": "test's quotes", "param2": "\"To be or not to be\" - Hamlet"}"""

The Json have the following spec:

  • Double quotes are used to quote string values,
  • double quotes inside of string values are backslash escaped,
  • and single quotes may appear unescaped inside of a string value.
Advertising

4 - Documentation / Reference