role doesn't fail cleanly there are no variables to check in inventory
Given:
#role/vars/main.yaml
---
example_variable_schema:
$schema: https://json-schema.org/draft-07/schema
type: object
properties:
example_integer:
type: integer
minimum: 0
maximum: 65535
When validate_role_parameters
is run with:
- no variables whose names start with
example_
, - variables whose names start with
example_
but are not defined inexample_variable_schema.properties
.
example
role validation fails with this error message:
PLAY [Run] ***********************************************************************************
TASK [Gathering Facts] ***********************************************************************
ok: [localhost]
TASK [validate_role_parameters : Validating arguments against arg spec 'main'] ***************
ok: [localhost]
TASK [validate_role_parameters : Include_tasks | Ensure role can be run] *********************
included: /REDACTED/playbook/REDACTED/role/validate_role_parameters/tasks/check.yaml for localhost
TASK [validate_role_parameters : Fail | Is role imported or included ?] **********************
skipping: [localhost]
TASK [validate_role_parameters : Fail | Does <role_name>_variable_schema exist ?] ************
skipping: [localhost]
TASK [validate_role_parameters : Include_tasks | Validate role parameters] *******************
included: /REDACTED/playbook/REDACTED/role/validate_role_parameters/tasks/validate.yaml for localhost
TASK [validate_role_parameters : Set_fact | gather role variables for {{ validate_role_parameter_role }}] ***
skipping: [localhost] => (item=example_variable)
skipping: [localhost]
TASK [validate_role_parameters : Validate | ensure role variables are properly defined] ******
fatal: [localhost]: FAILED! =>
msg: |-
The task includes an option with an undefined variable. The error was: 'validate_role_parameter_parent_variable' is undefined. 'validate_role_parameter_parent_variable' is undefined
The error appears to be in '/REDACTED/playbook/REDACTED/role/validate_role_parameters/tasks/validate.yaml': line 20, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Validate | ensure role variables are properly defined
^ here
PLAY RECAP ***********************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=1 skipped=3 rescued=0 ignored=0