I have the following json schema:
{
...
"properties": {
"gitlabUrl": {
"description": "URL of the GitLab instance to use",
"type": "string",
"default": "https://gitlab.com"
},
"gitlabApiVersion": {
"description": "Version of the GitLab API to use",
"type": "string",
"enum": [ "v3", "v4" ],
"default": "v4"
},
"gitlabAccessToken": {
"description": "Personal access token for accessing the GitLab API",
"type": "string"
}
},
"required": [
"gitlabAccessToken"
]
}
Only gitlabAccessToken is a mandory property. Consider a config of the above schema which contains only the gitlabAccessToken property:
{
"gitlabAccessToken": "XXXXXXXXXXXXXXXX"
}
If I pass the above config to my Ansible role which has the following task file:
---
- name: check variables
debug:
msg:
- "gitlabUrl: {{ gitlabUrl }}"
- "gitlabApiVersion: {{ gitlabApiVersion }}"
- "gitlabAccessToken: {{ gitlabccessToken }}"
Ansible will complain that gitlabUrl and gitlabApiVersion are undefined. I don't want to make gitlabUrl and gitlabApiVersion mandatory in the json schema, but I still want these two variables to be automatically defined in Ansible with the default values specified in the json schema. How can I achieve this?