New in version 2.5.
Parameter |
Choices/Defaults |
Comments |
---|---|---|
pool
|
|
A custom pool of variables to operate on as opposed to the pool all defined variables.
List of dicts.
|
rules
|
|
The rules to use for validating the variables.
Required if
rules_rules is not set. |
banner
|
|
The title to display for the offenses found for this rule
|
state
required |
|
If
deprecated , a warning will be printed if the variable is found to be definedIf
invalid , the task will fail if the variable's value passes the test specified in when If
required , the task will fail if the variable is not defined or evalutes to an empty stringIf
suspicious , the task will not fail but a warning is provided that the (matching) variables are potentially invalid. |
hint
|
|
A message to help the user address the problem if the rule applies
aliases: msg |
path
required |
|
Variable path or glob expression
|
banner_color
|
|
ANSI terminal color to use for the banner message. For example,
blue would be "0;34", black "0;30" and "0" for no coloring. See
https://github.com/ansible/ansible/blob/v2.5.6/lib/ansible/utils/color.py#L57
for the full listing.
|
hint_wrap
|
|
Whether to apply text-wrapping to multiline hint messages
|
when
|
|
Condition to use for filtering the selected variables based on their value
The content is a Jinja2 Test
The special (string) variable "item" will point to the value of the variable matched in
path .The special (list of strings) variable "captures" will contain the keys expanded by the "*" glob expression (if any).
When globbing (i.e. using the "*" expression), the special variable "item" is always coerced to string even if the value is not defined. If you need to test whether the value is defined, use "item == ''" or "item != ''" instead of the "defined()" test.
Required when state=invalid
Required when state=suspicious
|
rules_file
|
|
YAML file containing the rules to use.
Required if
rules is not set. |
- name: validate configuration
lint:
rules:
# inform the user of a change in the configuration so that they can update:
- state: deprecated
path: secrets.artifactory.api_token
hint: 'rename to "artifactory_api_token"'
# apply to a set of variables:
- state: deprecated
path: secrets.jfrog.*
hint: 'rename to "artifactory_*"'
# fail unless a variable be set:
- state: required
path: artifactory_api_token
# fail if a variable has an invalid value:
- state: invalid
path: services.*.address
when: item is not match('[\d\.]+')
hint: 'address must be an IP address (A record) not a hostname'
# require a value to be one of an enum:
- state: invalid
path: some_variable
when: item not in [ 'foo', 'bar', 'baz' ]
# warn about unrecognized properties:
- state: suspicious
path: services.*.*
when: captures[1] not in [ 'address', 'port' ]
banner: 'The following properties are not recognized:'
hint: 'please check for typos'
- name: load user settings
include_vars:
file: user_settings.yml
name: user_setting_pool
when: user_settings.yml is file
- name: validate user settings
lint:
pool:
- "{{ user_setting_pool }}"
- additional_var: 1
rules:
- state: deprecated
path: foo
Common return values are documented here, the following are the fields unique to this module:
Key |
Returned |
Description |
---|---|---|
issues
list
|
always |
The issues detected in the variables
Sample:
[{'path': 'foo', 'type': 'deprecated'}]
|
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Hint
If you notice any issues in this documentation you can edit this document to improve it.