diff --git a/f/ansible-playbook.json b/f/ansible-playbook.json index fbc2cf7b..4096af4a 100644 --- a/f/ansible-playbook.json +++ b/f/ansible-playbook.json @@ -195,8 +195,8 @@ "type": "array" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ @@ -455,8 +455,8 @@ "type": "array" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "serial": { "anyOf": [ @@ -640,8 +640,8 @@ "type": "string" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ @@ -867,8 +867,8 @@ "type": "integer" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ diff --git a/f/ansible-tasks.json b/f/ansible-tasks.json index 7b12a26a..936cf164 100644 --- a/f/ansible-tasks.json +++ b/f/ansible-tasks.json @@ -195,8 +195,8 @@ "type": "array" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ @@ -455,8 +455,8 @@ "type": "array" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "serial": { "anyOf": [ @@ -640,8 +640,8 @@ "type": "string" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ @@ -867,8 +867,8 @@ "type": "integer" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ diff --git a/f/ansible.json b/f/ansible.json index 689fd236..994c31c1 100644 --- a/f/ansible.json +++ b/f/ansible.json @@ -187,8 +187,8 @@ "type": "array" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ @@ -441,8 +441,8 @@ "type": "array" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "serial": { "anyOf": [ @@ -624,8 +624,8 @@ "type": "string" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ @@ -838,8 +838,8 @@ "type": "integer" }, "run_once": { - "title": "Run Once", - "type": "boolean" + "$ref": "#/definitions/templated-boolean", + "title": "Run Once" }, "tags": { "anyOf": [ diff --git a/negative_test/playbooks/run_once_list.yml b/negative_test/playbooks/run_once_list.yml new file mode 100644 index 00000000..0dd2cd55 --- /dev/null +++ b/negative_test/playbooks/run_once_list.yml @@ -0,0 +1,8 @@ +- hosts: localhost + tasks: + - name: foo2 + ansible.builtin.debug: + msg: foo! + run_once: # invalid due to schema, also ansible does not allow lists + - "{{ true }}" + - xxx diff --git a/negative_test/playbooks/run_once_list.yml.md b/negative_test/playbooks/run_once_list.yml.md new file mode 100644 index 00000000..817c989d --- /dev/null +++ b/negative_test/playbooks/run_once_list.yml.md @@ -0,0 +1,170 @@ +# ajv errors + +```json +[ + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'ansible.builtin.import_playbook'", + "params": { + "missingProperty": "ansible.builtin.import_playbook" + }, + "schemaPath": "#/definitions/ansible.builtin.import_playbook/oneOf/0/required" + }, + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'import_playbook'", + "params": { + "missingProperty": "import_playbook" + }, + "schemaPath": "#/definitions/ansible.builtin.import_playbook/oneOf/1/required" + }, + { + "instancePath": "/0", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/definitions/ansible.builtin.import_playbook/oneOf" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "hosts" + }, + "schemaPath": "#/definitions/ansible.builtin.import_playbook/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "tasks" + }, + "schemaPath": "#/definitions/ansible.builtin.import_playbook/additionalProperties" + }, + { + "instancePath": "/0/tasks/0/run_once", + "keyword": "type", + "message": "must be boolean", + "params": { + "type": "boolean" + }, + "schemaPath": "#/oneOf/0/type" + }, + { + "instancePath": "/0/tasks/0/run_once", + "keyword": "type", + "message": "must be string", + "params": { + "type": "string" + }, + "schemaPath": "#/oneOf/1/type" + }, + { + "instancePath": "/0/tasks/0/run_once", + "keyword": "type", + "message": "must be string", + "params": { + "type": "string" + }, + "schemaPath": "#/definitions/full-jinja/type" + }, + { + "instancePath": "/0/tasks/0/run_once", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/oneOf" + }, + { + "instancePath": "/0/tasks/0", + "keyword": "required", + "message": "must have required property 'block'", + "params": { + "missingProperty": "block" + }, + "schemaPath": "#/required" + }, + { + "instancePath": "/0/tasks/0/run_once", + "keyword": "type", + "message": "must be boolean", + "params": { + "type": "boolean" + }, + "schemaPath": "#/oneOf/0/type" + }, + { + "instancePath": "/0/tasks/0/run_once", + "keyword": "type", + "message": "must be string", + "params": { + "type": "string" + }, + "schemaPath": "#/oneOf/1/type" + }, + { + "instancePath": "/0/tasks/0/run_once", + "keyword": "type", + "message": "must be string", + "params": { + "type": "string" + }, + "schemaPath": "#/definitions/full-jinja/type" + }, + { + "instancePath": "/0/tasks/0/run_once", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/oneOf" + }, + { + "instancePath": "/0/tasks/0", + "keyword": "anyOf", + "message": "must match a schema in anyOf", + "params": {}, + "schemaPath": "#/items/anyOf" + }, + { + "instancePath": "/0", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/items/oneOf" + } +] +``` + +# check-jsonschema + +stdout: + +```json +{ + "status": "fail", + "errors": [ + { + "filename": "negative_test/playbooks/run_once_list.yml", + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'name': 'foo2', 'ansible.builtin.debug': {'msg': 'foo!'}, 'run_once': ['{{ true }}', 'xxx']}]} is not valid under any of the given schemas", + "has_sub_errors": true, + "best_match": { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'vars'" + } + } + ] +} +``` diff --git a/test/playbooks/run_once.yml b/test/playbooks/run_once.yml new file mode 100644 index 00000000..be36c8e1 --- /dev/null +++ b/test/playbooks/run_once.yml @@ -0,0 +1,6 @@ +- hosts: localhost + tasks: + - name: foo2 + ansible.builtin.debug: + msg: foo! + run_once: "{{ true }}" # valid diff --git a/test/playbooks/tasks/run_once.yml b/test/playbooks/tasks/run_once.yml new file mode 100644 index 00000000..0f3f6f71 --- /dev/null +++ b/test/playbooks/tasks/run_once.yml @@ -0,0 +1,9 @@ +- name: foo + ansible.builtin.debug: + msg: foo! + run_once: true # valid + +- name: foo2 + ansible.builtin.debug: + msg: foo! + run_once: "{{ true }}" # valid