short_description:Convert JSON string into variable structure
description:
- Converts a JSON string representation into an equivalent structured Ansible variable.
- Ansible internally auto-converts JSON strings into variable structures in most contexts, this plugin is used for those contexts it doesn't.
- Ansible automatically converts JSON strings into variable structures in most contexts, use this plugin in contexts where automatic conversion does not happen.
notes:
- This filter functions as a wrapper to the Python C(json.loads) function.
short_description:Convert YAML string into variable structure
description:
- Converts a YAML string representation into an equivalent structured Ansible variable.
- Ansible internally auto-converts YAML strings into variable structures in most contexts, this plugin is used for those contexts it doesn't.
- Ansible automatically converts YAML strings into variable structures in most contexts, use this plugin in contexts where automatic conversion does not happen.
notes:
- This filter functions as a wrapper to the Python pyyaml library's ``yaml.safe_load()`` function.
- This filter functions as a wrapper to the L(Python pyyaml library, https://pypi.org/project/PyYAML/)'s C(yaml.safe_load) function.
options:
_input:
description:A YAML string.
@ -21,5 +21,5 @@ EXAMPLES: |
RETURN:
_value:
description:the variable resuliting from deserializing the YAML document.
description:The variable resulting from deserializing the YAML document.
- Ansible internally auto-converts YAML strings into variable structures in most contexts, but by default does not handle 'multi document' YAML files or strings.
- If multiple YAML documents are not supplied, this is the equivalend of using C(from_yaml).
notes:
- This filter functions as a wrapper to the Python ``yaml.safe_load_all()`` function, part of the pyyaml python library
- This filter functions as a wrapper to the Python C(yaml.safe_load_all) function, part of the L(pyyaml Python library, https://pypi.org/project/PyYAML/).
- Possible conflicts in variable names from the mulitple documents are resolved directly by the pyyaml library.
options:
_input:
@ -24,5 +24,5 @@ EXAMPLES: |
RETURN:
_value:
description:the variable resuliting from deserializing the YAML documents.
description:The variable resulting from deserializing the YAML documents.
- Use the intput to either select a random element of a list or generate a random number
notes:
- This is a passthrough to Python's C(shelex.quote)
- Use the input to either select a random element of a list or generate a random number.
positional:_input, start, step, seed
options:
_input:
description:A number or list/sequence, if it is a number it is the top bound for random number generation, if it is a sequence or list, the source of the random element selected
description:A number or list/sequence, if it is a number it is the top bound for random number generation, if it is a sequence or list, the source of the random element selected.
type:raw
required:true
start:
description:bottom bound for the random number/element generated
description:Bottom bound for the random number/element generated.
type:int
step:
description:subsets the defined range by only using this value to select the increments of it between start and end
description:Subsets the defined range by only using this value to select the increments of it between start and end.
type:int
default:1
seed:
description:if specified use a pseudo random selection instead (repeatable)
description:If specified use a pseudo random selection instead (repeatable).
short_description:retuns a product of a list and it's elements
positional:_input, _subelement, skip_missing
description:
- This produces a product of an object and the subelement values of that object, similar to the subelements lookup. This lets you specify individual subelements to use in a template _input
- This produces a product of an object and the subelement values of that object, similar to the subelements lookup. This lets you specify individual subelements to use in a template I(_input).
options:
_input:
description:Original list
description:Original list.
type:list
elements:any
required:yes
_subelement:
description:Label of property to extract from original list items
description:Label of property to extract from original list items.
type:str
required:yes
skip_missing:
description:if C(True), ignore missing subelements, otherwise it is an error.
- Using the input string attempt to create a matching Python datetime object
- Using the input string attempt to create a matching Python C(datetime) object.
notes:
- For a full list of format codes for working with python date format strings, see https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior.
- For a full list of format codes for working with Python date format strings, see
- Converts an Ansible variable into a JSON string representation.
- This filter functions as a wrapper to the Python ``json.dumps()`` function.
- This filter functions as a wrapper to the Python C(json.dumps) function.
- Ansible internally auto-converts JSON strings into variable structures so this plugin is used to force it into a JSON string.
options:
_input:
@ -13,18 +13,18 @@ DOCUMENTATION:
type:raw
required:true
vault_to_text:
description:Toggle to either unvault a vault or create the JSON version of a vaulted object
description:Toggle to either unvault a vault or create the JSON version of a vaulted object.
type:bool
default:True
version_added:'2.9'
preprocess_unsafe:
description:Toggle to represent unsafe values directly in JSON or create a unsafe object in JSON
description:Toggle to represent unsafe values directly in JSON or create a unsafe object in JSON.
type:bool
default:True
version_added:'2.9'
allow_nan:
description:When off, strict adherence to float value limits of the JSON spec, so C(nan), C(inf) and C(-inf) values will produce errors
If on, JavaScript equivalents will be used (C(NaN), C(Infinity), C(-Infinity))
description:When C(False), strict adherence to float value limits of the JSON specifications, so C(nan), C(inf) and C(-inf) values will produce errors.
When C(True), JavaScript equivalents will be used (C(NaN), C(Infinity), C(-Infinity)).
default:True
type:bool
check_circular:
@ -32,29 +32,29 @@ DOCUMENTATION:
default:True
type:bool
ensure_ascii:
description:Escapes all non ASCII characters
description:Escapes all non ASCII characters.
default:True
type:bool
indent:
description:Number of spaces to indent python structures, mainly used for display to humans
description:Number of spaces to indent Python structures, mainly used for display to humans.
default:0
type:integer
separators:
description:The C(item) and C(key) separator to be used in the serialized output,
default may change depending on I(indent) and Python version
default may change depending on I(indent) and Python version.
default:"(', ', ': ')"
type:tuple
skipkeys:
description:If C(True), keys that are not basic Python types will be skipped
description:If C(True), keys that are not basic Python types will be skipped.
default:False
type:bool
sort_keys:
description:Affects sorting of dictionary keys
description:Affects sorting of dictionary keys.
default:False
type:bool
notes:
- Both I(vault_to_text) and I(preprocess_unsafe) defaulted to C(False) between Ansible 2.9 and 2.12
- 'These parameters to ``json.dumps()`` will be ignored, as they are overriden internally:I(cls), I(default)'
- Both I(vault_to_text) and I(preprocess_unsafe) defaulted to C(False) between Ansible 2.9 and 2.12.
- 'These parameters to C(json.dumps) will be ignored, as they are overriden internally:I(cls), I(default)'
EXAMPLES:|
# dump variable in a template to create a JSON document
@ -65,5 +65,5 @@ EXAMPLES: |
RETURN:
_value:
description:The JSON serialized string representing the variable structure inputted
description:The JSON serialized string representing the variable structure inputted.
short_description:Convert variable to 'nicely formatted' JSON string
description:
- Converts an Ansible variable into a 'nicely formatted' JSON string representation
- This filter functions as a wrapper to the Python ``json.dumps()`` function
- Ansible internally auto-converts JSON strings into variable structures so this plugin is used to force it into a JSON string
- This filter functions as a wrapper to the Python C(json.dumps) function.
- Ansible automatically converts JSON strings into variable structures so this plugin is used to forcibly retain a JSON string.
options:
_input:
description:A variable or expression that returns a data structure
description:A variable or expression that returns a data structure.
type:raw
required:true
vault_to_text:
description:Toggle to either unvault a vault or create the JSON version of a vaulted object
description:Toggle to either unvault a vault or create the JSON version of a vaulted object.
type:bool
default:True
version_added:'2.9'
preprocess_unsafe:
description:Toggle to represent unsafe values directly in JSON or create a unsafe object in JSON
description:Toggle to represent unsafe values directly in JSON or create a unsafe object in JSON.
type:bool
default:True
version_added:'2.9'
allow_nan:
description:When off, strict adherence to float value limits of the JSON spec, so C(nan), C(inf) and C(-inf) values will produce errors
If on, JavaScript equivalents will be used (C(NaN), C(Infinity), C(-Infinity)).
description:When C(False), strict adherence to float value limits of the JSON specification, so C(nan), C(inf) and C(-inf) values will produce errors.
When C(True), JavaScript equivalents will be used (C(NaN), C(Infinity), C(-Infinity)).
default:True
type:bool
check_circular:
@ -32,7 +32,7 @@ DOCUMENTATION:
default:True
type:bool
ensure_ascii:
description:Escapes all non ASCII characters
description:Escapes all non ASCII characters.
default:True
type:bool
skipkeys:
@ -40,8 +40,8 @@ DOCUMENTATION:
default:False
type:bool
notes:
- Both I(vault_to_text) and I(preprocess_unsafe) defaulted to C(False) between Ansible 2.9 and 2.12
- 'These parameters to ``json.dumps()`` will be ignored, they are overriden for internal use:I(cls), I(default), I(indent), I(separators), I(sort_keys).'
- Both I(vault_to_text) and I(preprocess_unsafe) defaulted to C(False) between Ansible 2.9 and 2.12.
- 'These parameters to C(json.dumps) will be ignored, they are overriden for internal use:I(cls), I(default), I(indent), I(separators), I(sort_keys).'
EXAMPLES:|
# dump variable in a template to create a nicely formatted JSON document