From 812776e2274aa7de1dae6bc37dec0be9b0b1b6ed Mon Sep 17 00:00:00 2001 From: Arnaud Patard Date: Wed, 22 Jun 2022 16:50:56 +0200 Subject: [PATCH 1/3] src/schema.spec.ts: Call check-jsonschema with -v Since support for import_playbooks has been added, the output of check-jsonschema will only output the error due to the play not matching the import_playbook schema (which is a normal thing) but won't show the actual error, so use -v to see all errors. Signed-off-by: Arnaud Patard --- negative_test/playbooks/environment.yml.md | 32 ++++++++- negative_test/playbooks/failed_when.yml.md | 44 +++++++++++- negative_test/playbooks/ignore_errors.yml.md | 52 +++++++++++++- .../playbooks/import_playbook.yml.md | 20 +++++- .../import_playbook_exclusive.yml.md | 32 ++++++++- .../playbooks/invalid-failed-when.yml.md | 68 ++++++++++++++++++- negative_test/playbooks/invalid-serial.yml.md | 36 +++++++++- negative_test/playbooks/invalid.yml.md | 16 ++++- negative_test/playbooks/invalid_become.yml.md | 32 ++++++++- negative_test/playbooks/local_action.yml.md | 32 ++++++++- negative_test/playbooks/loop.yml.md | 32 ++++++++- negative_test/playbooks/loop2.yml.md | 32 ++++++++- .../playbooks/no_log_partial_template.yml.md | 52 +++++++++++++- negative_test/playbooks/no_log_string.yml.md | 52 +++++++++++++- negative_test/playbooks/roles.yml.md | 24 ++++++- negative_test/playbooks/run_once_list.yml.md | 52 +++++++++++++- negative_test/playbooks/tags-mapping.yml.md | 44 +++++++++++- negative_test/playbooks/tags-number.yml.md | 44 +++++++++++- negative_test/playbooks/tasks.yml.md | 36 +++++++++- .../playbooks/tasks/args_integer.yml.md | 20 +++++- .../playbooks/tasks/args_string.yml.md | 20 +++++- .../tasks/become_method_untemplated.yml.md | 32 ++++++++- .../playbooks/tasks/ignore_errors.yml.md | 32 ++++++++- .../playbooks/tasks/invalid_block.yml.md | 12 +++- .../playbooks/tasks/local_action.yml.md | 12 +++- negative_test/playbooks/tasks/loop.yml.md | 12 +++- negative_test/playbooks/tasks/loop2.yml.md | 12 +++- .../playbooks/tasks/no_log_number.yml.md | 32 ++++++++- .../playbooks/tasks/no_log_string.yml.md | 32 ++++++++- .../playbooks/tasks/tags-mapping.yml.md | 32 ++++++++- .../playbooks/tasks/tags-string.yml.md | 32 ++++++++- .../playbooks/tasks/when_integer.yml.md | 40 ++++++++++- .../playbooks/tasks/when_object.yml.md | 40 ++++++++++- .../playbooks/tasks/with_items_boolean.yml.md | 20 +++++- .../with_items_untemplated_string.yml.md | 20 +++++- negative_test/playbooks/vars/asterisk.yml.md | 16 ++++- .../playbooks/vars/dash-in-var-name.yml.md | 16 ++++- negative_test/playbooks/vars/list.yml.md | 16 ++++- .../playbooks/vars/numeric-var-name.yml.md | 16 ++++- .../playbooks/vars/play-keyword.yml.md | 16 ++++- .../playbooks/vars/python-keyword.yml.md | 16 ++++- .../vars/varname-numeric-prefix.yml.md | 16 ++++- negative_test/playbooks/vas_prompt.yml.md | 28 +++++++- negative_test/playbooks/with_cartesian.yml.md | 32 ++++++++- negative_test/playbooks/with_filetree.yml.md | 32 ++++++++- negative_test/playbooks/with_flattened.yml.md | 32 ++++++++- negative_test/reqs3/meta/requirements.yml.md | 24 ++++++- negative_test/roles/meta/main.yml.md | 12 +++- .../meta_invalid_collection/meta/main.yml.md | 12 +++- .../meta_invalid_collections/meta/main.yml.md | 12 +++- .../meta/main.yml.md | 12 +++- .../meta/main.yml.md | 24 ++++++- src/schema.spec.ts | 2 +- 53 files changed, 1413 insertions(+), 53 deletions(-) diff --git a/negative_test/playbooks/environment.yml.md b/negative_test/playbooks/environment.yml.md index 85535cb5..35439dd2 100644 --- a/negative_test/playbooks/environment.yml.md +++ b/negative_test/playbooks/environment.yml.md @@ -100,7 +100,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'environment', 'hosts' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'environment', 'hosts' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'environment': '{{ foo }}-123'} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].environment", + "message": "'{{ foo }}-123' is not valid under any of the given schemas" + }, + { + "path": "$[0].environment", + "message": "'{{ foo }}-123' is not of type 'object'" + }, + { + "path": "$[0].environment", + "message": "'{{ foo }}-123' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + } + ] } ] } diff --git a/negative_test/playbooks/failed_when.yml.md b/negative_test/playbooks/failed_when.yml.md index 597a2e58..eac11fe4 100644 --- a/negative_test/playbooks/failed_when.yml.md +++ b/negative_test/playbooks/failed_when.yml.md @@ -127,7 +127,49 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'name': 'foo', 'ansible.builtin.debug': {'msg': 'foo!'}, 'failed_when': 123}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'name': 'foo', 'ansible.builtin.debug': {'msg': 'foo!'}, 'failed_when': 123} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].failed_when", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].failed_when", + "message": "123 is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].failed_when", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].tasks[0].failed_when", + "message": "123 is not of type 'array'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/ignore_errors.yml.md b/negative_test/playbooks/ignore_errors.yml.md index c2172628..91882ac9 100644 --- a/negative_test/playbooks/ignore_errors.yml.md +++ b/negative_test/playbooks/ignore_errors.yml.md @@ -145,7 +145,57 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'command': 'echo 123', 'vars': {'should_ignore_errors': True}, 'ignore_errors': 'should_ignore_errors'}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'command': 'echo 123', 'vars': {'should_ignore_errors': True}, 'ignore_errors': 'should_ignore_errors'} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].ignore_errors", + "message": "'should_ignore_errors' is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].ignore_errors", + "message": "'should_ignore_errors' is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].ignore_errors", + "message": "'should_ignore_errors' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].tasks[0].ignore_errors", + "message": "'should_ignore_errors' is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].ignore_errors", + "message": "'should_ignore_errors' is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].ignore_errors", + "message": "'should_ignore_errors' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/import_playbook.yml.md b/negative_test/playbooks/import_playbook.yml.md index c64cdafa..2812fc79 100644 --- a/negative_test/playbooks/import_playbook.yml.md +++ b/negative_test/playbooks/import_playbook.yml.md @@ -64,7 +64,25 @@ stdout: "best_match": { "path": "$[0]", "message": "Additional properties are not allowed ('ansible.builtin.import_playbook' was unexpected)" - } + }, + "sub_errors": [ + { + "path": "$[0].ansible.builtin.import_playbook", + "message": "{} is not of type 'string'" + }, + { + "path": "$[0]", + "message": "Additional properties are not allowed ('ansible.builtin.import_playbook' was unexpected)" + }, + { + "path": "$[0]", + "message": "{'ansible.builtin.import_playbook': {}} should not be valid under {'required': ['ansible.builtin.import_playbook']}" + }, + { + "path": "$[0]", + "message": "'hosts' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/import_playbook_exclusive.yml.md b/negative_test/playbooks/import_playbook_exclusive.yml.md index b25f4e7b..4b6a7356 100644 --- a/negative_test/playbooks/import_playbook_exclusive.yml.md +++ b/negative_test/playbooks/import_playbook_exclusive.yml.md @@ -94,7 +94,37 @@ stdout: "best_match": { "path": "$[0]", "message": "Additional properties are not allowed ('ansible.builtin.import_playbook', 'import_playbook' were unexpected)" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "{'ansible.builtin.import_playbook': 'foo.yml', 'import_playbook': 'other.yml'} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "{'ansible.builtin.import_playbook': 'foo.yml', 'import_playbook': 'other.yml'} should not be valid under {'required': ['import_playbook']}" + }, + { + "path": "$[0]", + "message": "{'ansible.builtin.import_playbook': 'foo.yml', 'import_playbook': 'other.yml'} should not be valid under {'required': ['ansible.builtin.import_playbook']}" + }, + { + "path": "$[0]", + "message": "Additional properties are not allowed ('ansible.builtin.import_playbook', 'import_playbook' were unexpected)" + }, + { + "path": "$[0]", + "message": "{'ansible.builtin.import_playbook': 'foo.yml', 'import_playbook': 'other.yml'} should not be valid under {'required': ['ansible.builtin.import_playbook']}" + }, + { + "path": "$[0]", + "message": "{'ansible.builtin.import_playbook': 'foo.yml', 'import_playbook': 'other.yml'} should not be valid under {'required': ['import_playbook']}" + }, + { + "path": "$[0]", + "message": "'hosts' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/invalid-failed-when.yml.md b/negative_test/playbooks/invalid-failed-when.yml.md index a6cd6b2d..ba590212 100644 --- a/negative_test/playbooks/invalid-failed-when.yml.md +++ b/negative_test/playbooks/invalid-failed-when.yml.md @@ -179,7 +179,73 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'debug': {'msg': 'failed_when should not accept numeric'}, 'failed_when': 123}, {'debug': {'msg': 'failed_when should not accept sequence'}, 'failed_when': ['foo', 'bar']}, {'debug': {'msg': 'failed_when should not accept map'}, 'failed_when': {}}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'debug': {'msg': 'failed_when should not accept numeric'}, 'failed_when': 123} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].failed_when", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].failed_when", + "message": "123 is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].failed_when", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].tasks[0].failed_when", + "message": "123 is not of type 'array'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + }, + { + "path": "$[0].tasks[2]", + "message": "{'debug': {'msg': 'failed_when should not accept map'}, 'failed_when': {}} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[2].failed_when", + "message": "{} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[2].failed_when", + "message": "{} is not of type 'boolean'" + }, + { + "path": "$[0].tasks[2].failed_when", + "message": "{} is not of type 'string'" + }, + { + "path": "$[0].tasks[2].failed_when", + "message": "{} is not of type 'array'" + }, + { + "path": "$[0].tasks[2]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/invalid-serial.yml.md b/negative_test/playbooks/invalid-serial.yml.md index e6b3c3c5..a4f14add 100644 --- a/negative_test/playbooks/invalid-serial.yml.md +++ b/negative_test/playbooks/invalid-serial.yml.md @@ -109,7 +109,41 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'serial' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'serial' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'serial': '10%BAD'} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].serial", + "message": "'10%BAD' is not valid under any of the given schemas" + }, + { + "path": "$[0].serial", + "message": "'10%BAD' is not of type 'integer'" + }, + { + "path": "$[0].serial", + "message": "'10%BAD' does not match '^\\\\d+\\\\.?\\\\d*%?$'" + }, + { + "path": "$[0].serial", + "message": "'10%BAD' is not of type 'array'" + } + ] } ] } diff --git a/negative_test/playbooks/invalid.yml.md b/negative_test/playbooks/invalid.yml.md index 21d3996f..82535c26 100644 --- a/negative_test/playbooks/invalid.yml.md +++ b/negative_test/playbooks/invalid.yml.md @@ -55,7 +55,21 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts' does not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts' does not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "Additional properties are not allowed ('import_playbook' was unexpected)" + }, + { + "path": "$[0]", + "message": "{'name': 'foo', 'hosts': 'localhost', 'import_playbook': 'included.yml'} should not be valid under {'required': ['import_playbook']}" + } + ] } ] } diff --git a/negative_test/playbooks/invalid_become.yml.md b/negative_test/playbooks/invalid_become.yml.md index 4f3014da..ee9ba94f 100644 --- a/negative_test/playbooks/invalid_become.yml.md +++ b/negative_test/playbooks/invalid_become.yml.md @@ -102,7 +102,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'become', 'hosts' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'become', 'hosts' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'become': 'yes'} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].become", + "message": "'yes' is not valid under any of the given schemas" + }, + { + "path": "$[0].become", + "message": "'yes' is not of type 'boolean'" + }, + { + "path": "$[0].become", + "message": "'yes' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + } + ] } ] } diff --git a/negative_test/playbooks/local_action.yml.md b/negative_test/playbooks/local_action.yml.md index 54d03da9..a3c2a4e0 100644 --- a/negative_test/playbooks/local_action.yml.md +++ b/negative_test/playbooks/local_action.yml.md @@ -103,7 +103,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'local_action': []}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'local_action': []} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].local_action", + "message": "[] is not of type 'string', 'object'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/loop.yml.md b/negative_test/playbooks/loop.yml.md index 2199b7cc..04a6278b 100644 --- a/negative_test/playbooks/loop.yml.md +++ b/negative_test/playbooks/loop.yml.md @@ -103,7 +103,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'name': 'that should pass', 'ansible.builtin.debug': {'var': 'item'}, 'loop': 123}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'name': 'that should pass', 'ansible.builtin.debug': {'var': 'item'}, 'loop': 123} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].loop", + "message": "123 is not of type 'string', 'array'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/loop2.yml.md b/negative_test/playbooks/loop2.yml.md index 76d56c86..4d804fdb 100644 --- a/negative_test/playbooks/loop2.yml.md +++ b/negative_test/playbooks/loop2.yml.md @@ -103,7 +103,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'name': 'that should pass', 'ansible.builtin.debug': {'var': 'item'}, 'loop': {}}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'name': 'that should pass', 'ansible.builtin.debug': {'var': 'item'}, 'loop': {}} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].loop", + "message": "{} is not of type 'string', 'array'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/no_log_partial_template.yml.md b/negative_test/playbooks/no_log_partial_template.yml.md index 1d8ad90b..4cb16872 100644 --- a/negative_test/playbooks/no_log_partial_template.yml.md +++ b/negative_test/playbooks/no_log_partial_template.yml.md @@ -145,7 +145,57 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'vars': {'some_var': True}, 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}, 'no_log': 'foo-{{ some_var }}'}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'ansible.builtin.debug': {'msg': 'foo'}, 'no_log': 'foo-{{ some_var }}'} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'foo-{{ some_var }}' is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'foo-{{ some_var }}' is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'foo-{{ some_var }}' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'foo-{{ some_var }}' is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'foo-{{ some_var }}' is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'foo-{{ some_var }}' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/no_log_string.yml.md b/negative_test/playbooks/no_log_string.yml.md index eb546808..24c56de7 100644 --- a/negative_test/playbooks/no_log_string.yml.md +++ b/negative_test/playbooks/no_log_string.yml.md @@ -145,7 +145,57 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'vars': {'some_var': True}, 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}, 'no_log': 'some_var'}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'ansible.builtin.debug': {'msg': 'foo'}, 'no_log': 'some_var'} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'some_var' is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'some_var' is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'some_var' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'some_var' is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'some_var' is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].no_log", + "message": "'some_var' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/roles.yml.md b/negative_test/playbooks/roles.yml.md index fa9aa504..488d727a 100644 --- a/negative_test/playbooks/roles.yml.md +++ b/negative_test/playbooks/roles.yml.md @@ -84,7 +84,29 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'roles' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'roles' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'roles': 'xxx'} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].roles", + "message": "'xxx' is not of type 'array'" + } + ] } ] } diff --git a/negative_test/playbooks/run_once_list.yml.md b/negative_test/playbooks/run_once_list.yml.md index 3384cceb..cf398291 100644 --- a/negative_test/playbooks/run_once_list.yml.md +++ b/negative_test/playbooks/run_once_list.yml.md @@ -163,7 +163,57 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "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" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'name': 'foo2', 'ansible.builtin.debug': {'msg': 'foo!'}, 'run_once': ['{{ true }}', 'xxx']} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].run_once", + "message": "['{{ true }}', 'xxx'] is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].run_once", + "message": "['{{ true }}', 'xxx'] is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].run_once", + "message": "['{{ true }}', 'xxx'] is not of type 'string'" + }, + { + "path": "$[0].tasks[0].run_once", + "message": "['{{ true }}', 'xxx'] is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0].run_once", + "message": "['{{ true }}', 'xxx'] is not of type 'boolean'" + }, + { + "path": "$[0].tasks[0].run_once", + "message": "['{{ true }}', 'xxx'] is not of type 'string'" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tags-mapping.yml.md b/negative_test/playbooks/tags-mapping.yml.md index 7fb45f39..b4969277 100644 --- a/negative_test/playbooks/tags-mapping.yml.md +++ b/negative_test/playbooks/tags-mapping.yml.md @@ -116,7 +116,49 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts' does not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts' does not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tags': {}} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tags", + "message": "{} is not valid under any of the given schemas" + }, + { + "path": "$[0].tags", + "message": "{} is not of type 'string'" + }, + { + "path": "$[0].tags", + "message": "{} is not of type 'array'" + }, + { + "path": "$[0].tags", + "message": "{} is not valid under any of the given schemas" + }, + { + "path": "$[0].tags", + "message": "{} is not of type 'string'" + }, + { + "path": "$[0].tags", + "message": "{} is not of type 'array'" + } + ] } ] } diff --git a/negative_test/playbooks/tags-number.yml.md b/negative_test/playbooks/tags-number.yml.md index 82bd9461..210931a0 100644 --- a/negative_test/playbooks/tags-number.yml.md +++ b/negative_test/playbooks/tags-number.yml.md @@ -116,7 +116,49 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts' does not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts' does not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tags': 123} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tags", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].tags", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].tags", + "message": "123 is not of type 'array'" + }, + { + "path": "$[0].tags", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].tags", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].tags", + "message": "123 is not of type 'array'" + } + ] } ] } diff --git a/negative_test/playbooks/tasks.yml.md b/negative_test/playbooks/tasks.yml.md index 141d9b79..96175cc1 100644 --- a/negative_test/playbooks/tasks.yml.md +++ b/negative_test/playbooks/tasks.yml.md @@ -150,7 +150,41 @@ stdout: "best_match": { "path": "$[0]", "message": "'handlers', 'hosts', 'post_tasks', 'pre_tasks', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'handlers', 'hosts', 'post_tasks', 'pre_tasks', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'pre_tasks': 'foo', 'post_tasks': {}, 'tasks': 1, 'handlers': 1.0} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].handlers", + "message": "1.0 is not of type 'array', 'null'" + }, + { + "path": "$[0].post_tasks", + "message": "{} is not of type 'array', 'null'" + }, + { + "path": "$[0].pre_tasks", + "message": "'foo' is not of type 'array', 'null'" + }, + { + "path": "$[0].tasks", + "message": "1 is not of type 'array', 'null'" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/args_integer.yml.md b/negative_test/playbooks/tasks/args_integer.yml.md index 5af092c8..0cd4403b 100644 --- a/negative_test/playbooks/tasks/args_integer.yml.md +++ b/negative_test/playbooks/tasks/args_integer.yml.md @@ -73,7 +73,25 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].args", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].args", + "message": "123 is not of type 'object'" + }, + { + "path": "$[0].args", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/args_string.yml.md b/negative_test/playbooks/tasks/args_string.yml.md index 21771006..44daf60a 100644 --- a/negative_test/playbooks/tasks/args_string.yml.md +++ b/negative_test/playbooks/tasks/args_string.yml.md @@ -64,7 +64,25 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].args", + "message": "'{{ }}123' is not valid under any of the given schemas" + }, + { + "path": "$[0].args", + "message": "'{{ }}123' is not of type 'object'" + }, + { + "path": "$[0].args", + "message": "'{{ }}123' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/become_method_untemplated.yml.md b/negative_test/playbooks/tasks/become_method_untemplated.yml.md index ba2c11d0..8114cc4c 100644 --- a/negative_test/playbooks/tasks/become_method_untemplated.yml.md +++ b/negative_test/playbooks/tasks/become_method_untemplated.yml.md @@ -111,7 +111,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].become_method", + "message": "'sudo_var' is not valid under any of the given schemas" + }, + { + "path": "$[0].become_method", + "message": "'sudo_var' is not one of ['sudo', 'su', 'pbrun', 'pfexec', 'runas', 'dzdo', 'ksu', 'doas', 'machinectl']" + }, + { + "path": "$[0].become_method", + "message": "'sudo_var' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].become_method", + "message": "'sudo_var' is not valid under any of the given schemas" + }, + { + "path": "$[0].become_method", + "message": "'sudo_var' is not one of ['sudo', 'su', 'pbrun', 'pfexec', 'runas', 'dzdo', 'ksu', 'doas', 'machinectl']" + }, + { + "path": "$[0].become_method", + "message": "'sudo_var' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/ignore_errors.yml.md b/negative_test/playbooks/tasks/ignore_errors.yml.md index a2842bc1..a3b318f8 100644 --- a/negative_test/playbooks/tasks/ignore_errors.yml.md +++ b/negative_test/playbooks/tasks/ignore_errors.yml.md @@ -91,7 +91,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].ignore_errors", + "message": "'should_ignore_errors' is not valid under any of the given schemas" + }, + { + "path": "$[0].ignore_errors", + "message": "'should_ignore_errors' is not of type 'boolean'" + }, + { + "path": "$[0].ignore_errors", + "message": "'should_ignore_errors' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].ignore_errors", + "message": "'should_ignore_errors' is not valid under any of the given schemas" + }, + { + "path": "$[0].ignore_errors", + "message": "'should_ignore_errors' is not of type 'boolean'" + }, + { + "path": "$[0].ignore_errors", + "message": "'should_ignore_errors' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/invalid_block.yml.md b/negative_test/playbooks/tasks/invalid_block.yml.md index 14cd6069..b86465bd 100644 --- a/negative_test/playbooks/tasks/invalid_block.yml.md +++ b/negative_test/playbooks/tasks/invalid_block.yml.md @@ -44,7 +44,17 @@ stdout: "best_match": { "path": "$[0]", "message": "{'block': {}} should not be valid under {'required': ['block']}" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "{'block': {}} should not be valid under {'required': ['block']}" + }, + { + "path": "$[0].block", + "message": "{} is not of type 'array'" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/local_action.yml.md b/negative_test/playbooks/tasks/local_action.yml.md index fcf34dc5..e624268f 100644 --- a/negative_test/playbooks/tasks/local_action.yml.md +++ b/negative_test/playbooks/tasks/local_action.yml.md @@ -49,7 +49,17 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].local_action", + "message": "[] is not of type 'string', 'object'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/loop.yml.md b/negative_test/playbooks/tasks/loop.yml.md index 3b9dde1f..5bbcb622 100644 --- a/negative_test/playbooks/tasks/loop.yml.md +++ b/negative_test/playbooks/tasks/loop.yml.md @@ -49,7 +49,17 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].loop", + "message": "{} is not of type 'string', 'array'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/loop2.yml.md b/negative_test/playbooks/tasks/loop2.yml.md index 6f176f29..1327d6ec 100644 --- a/negative_test/playbooks/tasks/loop2.yml.md +++ b/negative_test/playbooks/tasks/loop2.yml.md @@ -49,7 +49,17 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].loop", + "message": "123 is not of type 'string', 'array'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/no_log_number.yml.md b/negative_test/playbooks/tasks/no_log_number.yml.md index 3160193d..3db9a993 100644 --- a/negative_test/playbooks/tasks/no_log_number.yml.md +++ b/negative_test/playbooks/tasks/no_log_number.yml.md @@ -109,7 +109,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].no_log", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].no_log", + "message": "123 is not of type 'boolean'" + }, + { + "path": "$[0].no_log", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].no_log", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].no_log", + "message": "123 is not of type 'boolean'" + }, + { + "path": "$[0].no_log", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/no_log_string.yml.md b/negative_test/playbooks/tasks/no_log_string.yml.md index b0754f67..1d4ff2e2 100644 --- a/negative_test/playbooks/tasks/no_log_string.yml.md +++ b/negative_test/playbooks/tasks/no_log_string.yml.md @@ -91,7 +91,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].no_log", + "message": "'some_var' is not valid under any of the given schemas" + }, + { + "path": "$[0].no_log", + "message": "'some_var' is not of type 'boolean'" + }, + { + "path": "$[0].no_log", + "message": "'some_var' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].no_log", + "message": "'some_var' is not valid under any of the given schemas" + }, + { + "path": "$[0].no_log", + "message": "'some_var' is not of type 'boolean'" + }, + { + "path": "$[0].no_log", + "message": "'some_var' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/tags-mapping.yml.md b/negative_test/playbooks/tasks/tags-mapping.yml.md index 72a530ae..b3da5e76 100644 --- a/negative_test/playbooks/tasks/tags-mapping.yml.md +++ b/negative_test/playbooks/tasks/tags-mapping.yml.md @@ -87,7 +87,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].tags", + "message": "{} is not valid under any of the given schemas" + }, + { + "path": "$[0].tags", + "message": "{} is not of type 'string'" + }, + { + "path": "$[0].tags", + "message": "{} is not of type 'array'" + }, + { + "path": "$[0].tags", + "message": "{} is not valid under any of the given schemas" + }, + { + "path": "$[0].tags", + "message": "{} is not of type 'string'" + }, + { + "path": "$[0].tags", + "message": "{} is not of type 'array'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/tags-string.yml.md b/negative_test/playbooks/tasks/tags-string.yml.md index 221f249f..f240cc43 100644 --- a/negative_test/playbooks/tasks/tags-string.yml.md +++ b/negative_test/playbooks/tasks/tags-string.yml.md @@ -87,7 +87,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].tags", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].tags", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].tags", + "message": "123 is not of type 'array'" + }, + { + "path": "$[0].tags", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].tags", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].tags", + "message": "123 is not of type 'array'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/when_integer.yml.md b/negative_test/playbooks/tasks/when_integer.yml.md index 427e3501..73e3065c 100644 --- a/negative_test/playbooks/tasks/when_integer.yml.md +++ b/negative_test/playbooks/tasks/when_integer.yml.md @@ -109,7 +109,45 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].when", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].when", + "message": "123 is not of type 'boolean'" + }, + { + "path": "$[0].when", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].when", + "message": "123 is not of type 'array'" + }, + { + "path": "$[0].when", + "message": "123 is not valid under any of the given schemas" + }, + { + "path": "$[0].when", + "message": "123 is not of type 'boolean'" + }, + { + "path": "$[0].when", + "message": "123 is not of type 'string'" + }, + { + "path": "$[0].when", + "message": "123 is not of type 'array'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/when_object.yml.md b/negative_test/playbooks/tasks/when_object.yml.md index fb2de84d..2d739c93 100644 --- a/negative_test/playbooks/tasks/when_object.yml.md +++ b/negative_test/playbooks/tasks/when_object.yml.md @@ -109,7 +109,45 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].when", + "message": "{} is not valid under any of the given schemas" + }, + { + "path": "$[0].when", + "message": "{} is not of type 'boolean'" + }, + { + "path": "$[0].when", + "message": "{} is not of type 'string'" + }, + { + "path": "$[0].when", + "message": "{} is not of type 'array'" + }, + { + "path": "$[0].when", + "message": "{} is not valid under any of the given schemas" + }, + { + "path": "$[0].when", + "message": "{} is not of type 'boolean'" + }, + { + "path": "$[0].when", + "message": "{} is not of type 'string'" + }, + { + "path": "$[0].when", + "message": "{} is not of type 'array'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/with_items_boolean.yml.md b/negative_test/playbooks/tasks/with_items_boolean.yml.md index f0cf75ab..2ef80343 100644 --- a/negative_test/playbooks/tasks/with_items_boolean.yml.md +++ b/negative_test/playbooks/tasks/with_items_boolean.yml.md @@ -62,7 +62,25 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].with_items", + "message": "True is not valid under any of the given schemas" + }, + { + "path": "$[0].with_items", + "message": "True is not of type 'string'" + }, + { + "path": "$[0].with_items", + "message": "True is not of type 'array'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/tasks/with_items_untemplated_string.yml.md b/negative_test/playbooks/tasks/with_items_untemplated_string.yml.md index 5fd27aeb..68b6f421 100644 --- a/negative_test/playbooks/tasks/with_items_untemplated_string.yml.md +++ b/negative_test/playbooks/tasks/with_items_untemplated_string.yml.md @@ -62,7 +62,25 @@ stdout: "best_match": { "path": "$[0]", "message": "'block' is a required property" - } + }, + "sub_errors": [ + { + "path": "$[0].with_items", + "message": "'foobar' is not valid under any of the given schemas" + }, + { + "path": "$[0].with_items", + "message": "'foobar' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'" + }, + { + "path": "$[0].with_items", + "message": "'foobar' is not of type 'array'" + }, + { + "path": "$[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/vars/asterisk.yml.md b/negative_test/playbooks/vars/asterisk.yml.md index a2c38c34..f67567ff 100644 --- a/negative_test/playbooks/vars/asterisk.yml.md +++ b/negative_test/playbooks/vars/asterisk.yml.md @@ -55,7 +55,21 @@ stdout: "best_match": { "path": "$", "message": "'*foo' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "'*foo' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" + }, + { + "path": "$", + "message": "{'*foo': '...'} is not of type 'string'" + }, + { + "path": "$", + "message": "{'*foo': '...'} is not of type 'null'" + } + ] } ] } diff --git a/negative_test/playbooks/vars/dash-in-var-name.yml.md b/negative_test/playbooks/vars/dash-in-var-name.yml.md index 80eb7d40..061bceda 100644 --- a/negative_test/playbooks/vars/dash-in-var-name.yml.md +++ b/negative_test/playbooks/vars/dash-in-var-name.yml.md @@ -55,7 +55,21 @@ stdout: "best_match": { "path": "$", "message": "'foo-bar' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "'foo-bar' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" + }, + { + "path": "$", + "message": "{'foo-bar': '...'} is not of type 'string'" + }, + { + "path": "$", + "message": "{'foo-bar': '...'} is not of type 'null'" + } + ] } ] } diff --git a/negative_test/playbooks/vars/list.yml.md b/negative_test/playbooks/vars/list.yml.md index 6a0f3a9f..b1ff8960 100644 --- a/negative_test/playbooks/vars/list.yml.md +++ b/negative_test/playbooks/vars/list.yml.md @@ -55,7 +55,21 @@ stdout: "best_match": { "path": "$", "message": "['foo', 'bar'] is not of type 'object'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "['foo', 'bar'] is not of type 'object'" + }, + { + "path": "$", + "message": "['foo', 'bar'] is not of type 'string'" + }, + { + "path": "$", + "message": "['foo', 'bar'] is not of type 'null'" + } + ] } ] } diff --git a/negative_test/playbooks/vars/numeric-var-name.yml.md b/negative_test/playbooks/vars/numeric-var-name.yml.md index af58a858..dff8f3e1 100644 --- a/negative_test/playbooks/vars/numeric-var-name.yml.md +++ b/negative_test/playbooks/vars/numeric-var-name.yml.md @@ -55,7 +55,21 @@ stdout: "best_match": { "path": "$", "message": "'12' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "'12' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" + }, + { + "path": "$", + "message": "{'12': '...'} is not of type 'string'" + }, + { + "path": "$", + "message": "{'12': '...'} is not of type 'null'" + } + ] } ] } diff --git a/negative_test/playbooks/vars/play-keyword.yml.md b/negative_test/playbooks/vars/play-keyword.yml.md index 23d06cac..37cabcd1 100644 --- a/negative_test/playbooks/vars/play-keyword.yml.md +++ b/negative_test/playbooks/vars/play-keyword.yml.md @@ -55,7 +55,21 @@ stdout: "best_match": { "path": "$", "message": "'environment' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "'environment' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" + }, + { + "path": "$", + "message": "{'environment': '...'} is not of type 'string'" + }, + { + "path": "$", + "message": "{'environment': '...'} is not of type 'null'" + } + ] } ] } diff --git a/negative_test/playbooks/vars/python-keyword.yml.md b/negative_test/playbooks/vars/python-keyword.yml.md index 46ccf159..5778fa60 100644 --- a/negative_test/playbooks/vars/python-keyword.yml.md +++ b/negative_test/playbooks/vars/python-keyword.yml.md @@ -64,7 +64,21 @@ stdout: "best_match": { "path": "$", "message": "'async', 'lambda' do not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "'async', 'lambda' do not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" + }, + { + "path": "$", + "message": "{'async': '...', 'lambda': '...'} is not of type 'string'" + }, + { + "path": "$", + "message": "{'async': '...', 'lambda': '...'} is not of type 'null'" + } + ] } ] } diff --git a/negative_test/playbooks/vars/varname-numeric-prefix.yml.md b/negative_test/playbooks/vars/varname-numeric-prefix.yml.md index 5a9d4701..42cc7f9b 100644 --- a/negative_test/playbooks/vars/varname-numeric-prefix.yml.md +++ b/negative_test/playbooks/vars/varname-numeric-prefix.yml.md @@ -55,7 +55,21 @@ stdout: "best_match": { "path": "$", "message": "'5foo' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "'5foo' does not match any of the regexes: '^(?!(False|None|True|and|any_errors_fatal|as|assert|async|await|become|become_exe|become_flags|become_method|become_user|break|check_mode|class|collections|connection|continue|debugger|def|del|diff|elif|else|environment|except|fact_path|finally|for|force_handlers|from|gather_facts|gather_subset|gather_timeout|global|handlers|hosts|if|ignore_errors|ignore_unreachable|import|in|is|lambda|max_fail_percentage|module_defaults|name|no_log|nonlocal|not|or|order|pass|port|post_tasks|pre_tasks|raise|remote_user|return|roles|run_once|serial|strategy|tags|tasks|throttle|timeout|try|vars|vars_files|vars_prompt|while|with|yield)$)[a-zA-Z_][\\\\w]*$'" + }, + { + "path": "$", + "message": "{'5foo': '...'} is not of type 'string'" + }, + { + "path": "$", + "message": "{'5foo': '...'} is not of type 'null'" + } + ] } ] } diff --git a/negative_test/playbooks/vas_prompt.yml.md b/negative_test/playbooks/vas_prompt.yml.md index 3d06ee57..4903629f 100644 --- a/negative_test/playbooks/vas_prompt.yml.md +++ b/negative_test/playbooks/vas_prompt.yml.md @@ -84,7 +84,33 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts' does not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts' does not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'vars_prompt': [{'name': 'username', 'prompt': 'What is your username?', 'private': False, 'tags': ['foo']}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].vars_prompt", + "message": "[{'name': 'username', 'prompt': 'What is your username?', 'private': False, 'tags': ['foo']}] is not of type 'object'" + }, + { + "path": "$[0].vars_prompt[0]", + "message": "Additional properties are not allowed ('tags' was unexpected)" + } + ] } ] } diff --git a/negative_test/playbooks/with_cartesian.yml.md b/negative_test/playbooks/with_cartesian.yml.md index ae7d7a18..18ad5a2e 100644 --- a/negative_test/playbooks/with_cartesian.yml.md +++ b/negative_test/playbooks/with_cartesian.yml.md @@ -98,7 +98,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_cartesian': []}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_cartesian': []} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0]", + "message": "{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_cartesian': []} should not be valid under {'required': ['with_cartesian']}" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/with_filetree.yml.md b/negative_test/playbooks/with_filetree.yml.md index f7ee152e..c339614f 100644 --- a/negative_test/playbooks/with_filetree.yml.md +++ b/negative_test/playbooks/with_filetree.yml.md @@ -98,7 +98,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_filetree': 'foo'}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_filetree': 'foo'} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0]", + "message": "{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_filetree': 'foo'} should not be valid under {'required': ['with_filetree']}" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/playbooks/with_flattened.yml.md b/negative_test/playbooks/with_flattened.yml.md index 865c1686..5593c314 100644 --- a/negative_test/playbooks/with_flattened.yml.md +++ b/negative_test/playbooks/with_flattened.yml.md @@ -98,7 +98,37 @@ stdout: "best_match": { "path": "$[0]", "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" - } + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'tasks': [{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_flattened': 'foo'}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].tasks[0]", + "message": "{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_flattened': 'foo'} is not valid under any of the given schemas" + }, + { + "path": "$[0].tasks[0]", + "message": "{'ansible.builtin.debug': {'msg': '{{ item }}'}, 'with_flattened': 'foo'} should not be valid under {'required': ['with_flattened']}" + }, + { + "path": "$[0].tasks[0]", + "message": "'block' is a required property" + } + ] } ] } diff --git a/negative_test/reqs3/meta/requirements.yml.md b/negative_test/reqs3/meta/requirements.yml.md index 3c0b62ef..54ba9b28 100644 --- a/negative_test/reqs3/meta/requirements.yml.md +++ b/negative_test/reqs3/meta/requirements.yml.md @@ -71,7 +71,29 @@ stdout: "best_match": { "path": "$", "message": "{'foo': 'bar'} is not of type 'array'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "{'foo': 'bar'} is not of type 'array'" + }, + { + "path": "$", + "message": "Additional properties are not allowed ('foo' was unexpected)" + }, + { + "path": "$", + "message": "{'foo': 'bar'} is not valid under any of the given schemas" + }, + { + "path": "$", + "message": "'collections' is a required property" + }, + { + "path": "$", + "message": "'roles' is a required property" + } + ] } ] } diff --git a/negative_test/roles/meta/main.yml.md b/negative_test/roles/meta/main.yml.md index f9db9f67..469e5c0a 100644 --- a/negative_test/roles/meta/main.yml.md +++ b/negative_test/roles/meta/main.yml.md @@ -46,7 +46,17 @@ stdout: "best_match": { "path": "$", "message": "{'galaxy_info': {'description': 'bar', 'min_ansible_version': '2.9', 'company': 'foo', 'license': 'MIT', 'galaxy_tags': 'database', 'platforms': [{'name': 'Alpine', 'versions': ['all']}]}} is not of type 'null'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "{'galaxy_info': {'description': 'bar', 'min_ansible_version': '2.9', 'company': 'foo', 'license': 'MIT', 'galaxy_tags': 'database', 'platforms': [{'name': 'Alpine', 'versions': ['all']}]}} is not of type 'null'" + }, + { + "path": "$.galaxy_info.galaxy_tags", + "message": "'database' is not of type 'array'" + } + ] } ] } diff --git a/negative_test/roles/meta_invalid_collection/meta/main.yml.md b/negative_test/roles/meta_invalid_collection/meta/main.yml.md index 6238286f..5b4ea51a 100644 --- a/negative_test/roles/meta_invalid_collection/meta/main.yml.md +++ b/negative_test/roles/meta_invalid_collection/meta/main.yml.md @@ -46,7 +46,17 @@ stdout: "best_match": { "path": "$", "message": "{'collections': ['foo'], 'galaxy_info': {'description': 'foo', 'license': 'bar', 'min_ansible_version': '2.10', 'platforms': [{'name': 'Fedora', 'versions': ['all']}]}} is not of type 'null'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "{'collections': ['foo'], 'galaxy_info': {'description': 'foo', 'license': 'bar', 'min_ansible_version': '2.10', 'platforms': [{'name': 'Fedora', 'versions': ['all']}]}} is not of type 'null'" + }, + { + "path": "$.collections[0]", + "message": "'foo' does not match '^[a-z_]+\\\\.[a-z_]+$'" + } + ] } ] } diff --git a/negative_test/roles/meta_invalid_collections/meta/main.yml.md b/negative_test/roles/meta_invalid_collections/meta/main.yml.md index 6d229fb6..6d851da7 100644 --- a/negative_test/roles/meta_invalid_collections/meta/main.yml.md +++ b/negative_test/roles/meta_invalid_collections/meta/main.yml.md @@ -46,7 +46,17 @@ stdout: "best_match": { "path": "$", "message": "{'collections': ['FOO.BAR'], 'galaxy_info': {'description': 'foo', 'license': 'bar', 'min_ansible_version': '2.10', 'platforms': [{'name': 'Fedora', 'versions': ['all']}]}} is not of type 'null'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "{'collections': ['FOO.BAR'], 'galaxy_info': {'description': 'foo', 'license': 'bar', 'min_ansible_version': '2.10', 'platforms': [{'name': 'Fedora', 'versions': ['all']}]}} is not of type 'null'" + }, + { + "path": "$.collections[0]", + "message": "'FOO.BAR' does not match '^[a-z_]+\\\\.[a-z_]+$'" + } + ] } ] } diff --git a/negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md b/negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md index 3df5982a..f4682584 100644 --- a/negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md +++ b/negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md @@ -46,7 +46,17 @@ stdout: "best_match": { "path": "$", "message": "{'galaxy_info': {'description': 'foo', 'min_ansible_version': '2.9', 'namespace': 'foo-bar', 'company': 'foo', 'license': 'MIT', 'platforms': [{'name': 'Alpine', 'versions': ['all']}]}} is not of type 'null'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "{'galaxy_info': {'description': 'foo', 'min_ansible_version': '2.9', 'namespace': 'foo-bar', 'company': 'foo', 'license': 'MIT', 'platforms': [{'name': 'Alpine', 'versions': ['all']}]}} is not of type 'null'" + }, + { + "path": "$.galaxy_info.namespace", + "message": "'foo-bar' does not match '^[a-z][a-z0-9_]+$'" + } + ] } ] } diff --git a/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml.md b/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml.md index b128f11c..2f712d6f 100644 --- a/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml.md +++ b/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml.md @@ -71,7 +71,29 @@ stdout: "best_match": { "path": "$", "message": "{'galaxy_info': {'description': 'bar', 'min_ansible_version': '2.9', 'company': 'foo', 'license': 'MIT', 'platforms': [{'name': 'Alpine', 'versions': ['all']}]}, 'dependencies': [{'version': 'foo'}]} is not of type 'null'" - } + }, + "sub_errors": [ + { + "path": "$", + "message": "{'galaxy_info': {'description': 'bar', 'min_ansible_version': '2.9', 'company': 'foo', 'license': 'MIT', 'platforms': [{'name': 'Alpine', 'versions': ['all']}]}, 'dependencies': [{'version': 'foo'}]} is not of type 'null'" + }, + { + "path": "$.dependencies[0]", + "message": "{'version': 'foo'} is not valid under any of the given schemas" + }, + { + "path": "$.dependencies[0]", + "message": "'role' is a required property" + }, + { + "path": "$.dependencies[0]", + "message": "'src' is a required property" + }, + { + "path": "$.dependencies[0]", + "message": "'name' is a required property" + } + ] } ] } diff --git a/src/schema.spec.ts b/src/schema.spec.ts index b6f99787..e471e4f8 100644 --- a/src/schema.spec.ts +++ b/src/schema.spec.ts @@ -74,7 +74,7 @@ describe("schemas under f/", function () { // reason, nodejs environment lacks some env variables needed // and breaks usage from inside virtualenvs. const proc = spawnSync( - `check-jsonschema -o json --schemafile f/${schema_file} ${test_file}`, + `check-jsonschema -v -o json --schemafile f/${schema_file} ${test_file}`, { shell: true, encoding: "utf-8", stdio: "pipe" } ); if (proc.status != 0) { From 7e7598f63d801f348d4fe604dcae318d41a07b30 Mon Sep 17 00:00:00 2001 From: Arnaud Patard Date: Wed, 22 Jun 2022 17:04:26 +0200 Subject: [PATCH 2/3] f/: fix gather_subset type gather_subset is not a boolean but an array of string, so fix the definition and add various tests files for it. Signed-off-by: Arnaud Patard --- .config/dictionary.txt | 1 + f/ansible-playbook.json | 30 ++- f/ansible.json | 30 ++- negative_test/playbooks/gather_subset.yml | 6 + negative_test/playbooks/gather_subset.yml.md | 122 ++++++++++++ negative_test/playbooks/gather_subset2.yml | 7 + negative_test/playbooks/gather_subset2.yml.md | 162 +++++++++++++++ negative_test/playbooks/gather_subset3.yml | 7 + negative_test/playbooks/gather_subset3.yml.md | 188 ++++++++++++++++++ negative_test/playbooks/gather_subset4.yml | 6 + negative_test/playbooks/gather_subset4.yml.md | 122 ++++++++++++ test/playbooks/gather_subset.yml | 15 ++ 12 files changed, 694 insertions(+), 2 deletions(-) create mode 100644 negative_test/playbooks/gather_subset.yml create mode 100644 negative_test/playbooks/gather_subset.yml.md create mode 100644 negative_test/playbooks/gather_subset2.yml create mode 100644 negative_test/playbooks/gather_subset2.yml.md create mode 100644 negative_test/playbooks/gather_subset3.yml create mode 100644 negative_test/playbooks/gather_subset3.yml.md create mode 100644 negative_test/playbooks/gather_subset4.yml create mode 100644 negative_test/playbooks/gather_subset4.yml.md create mode 100644 test/playbooks/gather_subset.yml diff --git a/.config/dictionary.txt b/.config/dictionary.txt index 0e1769fb..ebb8edaf 100644 --- a/.config/dictionary.txt +++ b/.config/dictionary.txt @@ -25,6 +25,7 @@ dzdo ededed envlist eoan +facter fbba fbca fcba diff --git a/f/ansible-playbook.json b/f/ansible-playbook.json index 219c805d..ebbecbae 100644 --- a/f/ansible-playbook.json +++ b/f/ansible-playbook.json @@ -349,8 +349,36 @@ "type": "boolean" }, "gather_subset": { + "items": { + "anyOf": [ + { + "enum": [ + "all", + "min", + "hardware", + "network", + "virtual", + "ohai", + "facter" + ], + "type": "string" + }, + { + "enum": [ + "!all", + "!min", + "!hardware", + "!network", + "!virtual", + "!ohai", + "!facter" + ], + "type": "string" + } + ] + }, "title": "Gather Subset", - "type": "boolean" + "type": "array" }, "gather_timeout": { "$ref": "#/$defs/templated-integer", diff --git a/f/ansible.json b/f/ansible.json index 152bd249..f98bbb3b 100644 --- a/f/ansible.json +++ b/f/ansible.json @@ -334,8 +334,36 @@ "type": "boolean" }, "gather_subset": { + "items": { + "anyOf": [ + { + "enum": [ + "all", + "min", + "hardware", + "network", + "virtual", + "ohai", + "facter" + ], + "type": "string" + }, + { + "enum": [ + "!all", + "!min", + "!hardware", + "!network", + "!virtual", + "!ohai", + "!facter" + ], + "type": "string" + } + ] + }, "title": "Gather Subset", - "type": "boolean" + "type": "array" }, "gather_timeout": { "$ref": "#/$defs/templated-integer", diff --git a/negative_test/playbooks/gather_subset.yml b/negative_test/playbooks/gather_subset.yml new file mode 100644 index 00000000..455d683e --- /dev/null +++ b/negative_test/playbooks/gather_subset.yml @@ -0,0 +1,6 @@ +--- +- hosts: localhost + gather_subset: all + tasks: + - ansible.builtin.debug: + msg: foo diff --git a/negative_test/playbooks/gather_subset.yml.md b/negative_test/playbooks/gather_subset.yml.md new file mode 100644 index 00000000..62da3527 --- /dev/null +++ b/negative_test/playbooks/gather_subset.yml.md @@ -0,0 +1,122 @@ +# ajv errors + +```json +[ + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'ansible.builtin.import_playbook'", + "params": { + "missingProperty": "ansible.builtin.import_playbook" + }, + "schemaPath": "#/oneOf/0/required" + }, + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'import_playbook'", + "params": { + "missingProperty": "import_playbook" + }, + "schemaPath": "#/oneOf/1/required" + }, + { + "instancePath": "/0", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/oneOf" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "hosts" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "gather_subset" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "tasks" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0/gather_subset", + "keyword": "type", + "message": "must be array", + "params": { + "type": "array" + }, + "schemaPath": "#/properties/gather_subset/type" + }, + { + "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/gather_subset.yml", + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_subset': 'all', 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas", + "has_sub_errors": true, + "best_match": { + "path": "$[0]", + "message": "'gather_subset', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'gather_subset', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_subset': 'all', 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].gather_subset", + "message": "'all' is not of type 'array'" + } + ] + } + ] +} +``` diff --git a/negative_test/playbooks/gather_subset2.yml b/negative_test/playbooks/gather_subset2.yml new file mode 100644 index 00000000..d5a39ae8 --- /dev/null +++ b/negative_test/playbooks/gather_subset2.yml @@ -0,0 +1,7 @@ +--- +- hosts: localhost + gather_subset: + - invalid + tasks: + - ansible.builtin.debug: + msg: foo diff --git a/negative_test/playbooks/gather_subset2.yml.md b/negative_test/playbooks/gather_subset2.yml.md new file mode 100644 index 00000000..7c364216 --- /dev/null +++ b/negative_test/playbooks/gather_subset2.yml.md @@ -0,0 +1,162 @@ +# ajv errors + +```json +[ + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'ansible.builtin.import_playbook'", + "params": { + "missingProperty": "ansible.builtin.import_playbook" + }, + "schemaPath": "#/oneOf/0/required" + }, + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'import_playbook'", + "params": { + "missingProperty": "import_playbook" + }, + "schemaPath": "#/oneOf/1/required" + }, + { + "instancePath": "/0", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/oneOf" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "hosts" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "gather_subset" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "tasks" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0/gather_subset/0", + "keyword": "enum", + "message": "must be equal to one of the allowed values", + "params": { + "allowedValues": [ + "all", + "min", + "hardware", + "network", + "virtual", + "ohai", + "facter" + ] + }, + "schemaPath": "#/properties/gather_subset/items/anyOf/0/enum" + }, + { + "instancePath": "/0/gather_subset/0", + "keyword": "enum", + "message": "must be equal to one of the allowed values", + "params": { + "allowedValues": [ + "!all", + "!min", + "!hardware", + "!network", + "!virtual", + "!ohai", + "!facter" + ] + }, + "schemaPath": "#/properties/gather_subset/items/anyOf/1/enum" + }, + { + "instancePath": "/0/gather_subset/0", + "keyword": "anyOf", + "message": "must match a schema in anyOf", + "params": {}, + "schemaPath": "#/properties/gather_subset/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/gather_subset2.yml", + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_subset': ['invalid'], 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas", + "has_sub_errors": true, + "best_match": { + "path": "$[0]", + "message": "'gather_subset', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'gather_subset', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_subset': ['invalid'], 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].gather_subset[0]", + "message": "'invalid' is not valid under any of the given schemas" + }, + { + "path": "$[0].gather_subset[0]", + "message": "'invalid' is not one of ['all', 'min', 'hardware', 'network', 'virtual', 'ohai', 'facter']" + }, + { + "path": "$[0].gather_subset[0]", + "message": "'invalid' is not one of ['!all', '!min', '!hardware', '!network', '!virtual', '!ohai', '!facter']" + } + ] + } + ] +} +``` diff --git a/negative_test/playbooks/gather_subset3.yml b/negative_test/playbooks/gather_subset3.yml new file mode 100644 index 00000000..05e4028b --- /dev/null +++ b/negative_test/playbooks/gather_subset3.yml @@ -0,0 +1,7 @@ +--- +- hosts: localhost + gather_subset: + - 1 + tasks: + - ansible.builtin.debug: + msg: foo diff --git a/negative_test/playbooks/gather_subset3.yml.md b/negative_test/playbooks/gather_subset3.yml.md new file mode 100644 index 00000000..17eb403c --- /dev/null +++ b/negative_test/playbooks/gather_subset3.yml.md @@ -0,0 +1,188 @@ +# ajv errors + +```json +[ + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'ansible.builtin.import_playbook'", + "params": { + "missingProperty": "ansible.builtin.import_playbook" + }, + "schemaPath": "#/oneOf/0/required" + }, + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'import_playbook'", + "params": { + "missingProperty": "import_playbook" + }, + "schemaPath": "#/oneOf/1/required" + }, + { + "instancePath": "/0", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/oneOf" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "hosts" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "gather_subset" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "tasks" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0/gather_subset/0", + "keyword": "type", + "message": "must be string", + "params": { + "type": "string" + }, + "schemaPath": "#/properties/gather_subset/items/anyOf/0/type" + }, + { + "instancePath": "/0/gather_subset/0", + "keyword": "enum", + "message": "must be equal to one of the allowed values", + "params": { + "allowedValues": [ + "all", + "min", + "hardware", + "network", + "virtual", + "ohai", + "facter" + ] + }, + "schemaPath": "#/properties/gather_subset/items/anyOf/0/enum" + }, + { + "instancePath": "/0/gather_subset/0", + "keyword": "type", + "message": "must be string", + "params": { + "type": "string" + }, + "schemaPath": "#/properties/gather_subset/items/anyOf/1/type" + }, + { + "instancePath": "/0/gather_subset/0", + "keyword": "enum", + "message": "must be equal to one of the allowed values", + "params": { + "allowedValues": [ + "!all", + "!min", + "!hardware", + "!network", + "!virtual", + "!ohai", + "!facter" + ] + }, + "schemaPath": "#/properties/gather_subset/items/anyOf/1/enum" + }, + { + "instancePath": "/0/gather_subset/0", + "keyword": "anyOf", + "message": "must match a schema in anyOf", + "params": {}, + "schemaPath": "#/properties/gather_subset/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/gather_subset3.yml", + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_subset': [1], 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas", + "has_sub_errors": true, + "best_match": { + "path": "$[0]", + "message": "'gather_subset', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'gather_subset', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_subset': [1], 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].gather_subset[0]", + "message": "1 is not valid under any of the given schemas" + }, + { + "path": "$[0].gather_subset[0]", + "message": "1 is not one of ['all', 'min', 'hardware', 'network', 'virtual', 'ohai', 'facter']" + }, + { + "path": "$[0].gather_subset[0]", + "message": "1 is not of type 'string'" + }, + { + "path": "$[0].gather_subset[0]", + "message": "1 is not one of ['!all', '!min', '!hardware', '!network', '!virtual', '!ohai', '!facter']" + }, + { + "path": "$[0].gather_subset[0]", + "message": "1 is not of type 'string'" + } + ] + } + ] +} +``` diff --git a/negative_test/playbooks/gather_subset4.yml b/negative_test/playbooks/gather_subset4.yml new file mode 100644 index 00000000..816e6666 --- /dev/null +++ b/negative_test/playbooks/gather_subset4.yml @@ -0,0 +1,6 @@ +--- +- hosts: localhost + gather_subset: 1 + tasks: + - ansible.builtin.debug: + msg: foo diff --git a/negative_test/playbooks/gather_subset4.yml.md b/negative_test/playbooks/gather_subset4.yml.md new file mode 100644 index 00000000..62706bec --- /dev/null +++ b/negative_test/playbooks/gather_subset4.yml.md @@ -0,0 +1,122 @@ +# ajv errors + +```json +[ + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'ansible.builtin.import_playbook'", + "params": { + "missingProperty": "ansible.builtin.import_playbook" + }, + "schemaPath": "#/oneOf/0/required" + }, + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'import_playbook'", + "params": { + "missingProperty": "import_playbook" + }, + "schemaPath": "#/oneOf/1/required" + }, + { + "instancePath": "/0", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/oneOf" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "hosts" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "gather_subset" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "tasks" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0/gather_subset", + "keyword": "type", + "message": "must be array", + "params": { + "type": "array" + }, + "schemaPath": "#/properties/gather_subset/type" + }, + { + "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/gather_subset4.yml", + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_subset': 1, 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas", + "has_sub_errors": true, + "best_match": { + "path": "$[0]", + "message": "'gather_subset', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'gather_subset', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_subset': 1, 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].gather_subset", + "message": "1 is not of type 'array'" + } + ] + } + ] +} +``` diff --git a/test/playbooks/gather_subset.yml b/test/playbooks/gather_subset.yml new file mode 100644 index 00000000..de0e6891 --- /dev/null +++ b/test/playbooks/gather_subset.yml @@ -0,0 +1,15 @@ +--- +- hosts: localhost + gather_subset: + - all + - "!network" + tasks: + - ansible.builtin.debug: + msg: foo + +- hosts: localhost + gather_subset: + - all + tasks: + - ansible.builtin.debug: + msg: bar From cd246a39cbf5a771a42f28db2139de8ba69ac7bc Mon Sep 17 00:00:00 2001 From: Arnaud Patard Date: Wed, 22 Jun 2022 17:15:20 +0200 Subject: [PATCH 3/3] Add tests for gather_facts. While working on gather_subsets, thought it would be a good idea to add tests for gather_facts too. Signed-off-by: Arnaud Patard --- negative_test/playbooks/gather_facts.yml | 6 + negative_test/playbooks/gather_facts.yml.md | 122 ++++++++++++++++++++ test/playbooks/gather_facts.yml | 6 + 3 files changed, 134 insertions(+) create mode 100644 negative_test/playbooks/gather_facts.yml create mode 100644 negative_test/playbooks/gather_facts.yml.md create mode 100644 test/playbooks/gather_facts.yml diff --git a/negative_test/playbooks/gather_facts.yml b/negative_test/playbooks/gather_facts.yml new file mode 100644 index 00000000..d1b1345d --- /dev/null +++ b/negative_test/playbooks/gather_facts.yml @@ -0,0 +1,6 @@ +--- +- hosts: localhost + gather_facts: non + tasks: + - ansible.builtin.debug: + msg: foo diff --git a/negative_test/playbooks/gather_facts.yml.md b/negative_test/playbooks/gather_facts.yml.md new file mode 100644 index 00000000..2cd99452 --- /dev/null +++ b/negative_test/playbooks/gather_facts.yml.md @@ -0,0 +1,122 @@ +# ajv errors + +```json +[ + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'ansible.builtin.import_playbook'", + "params": { + "missingProperty": "ansible.builtin.import_playbook" + }, + "schemaPath": "#/oneOf/0/required" + }, + { + "instancePath": "/0", + "keyword": "required", + "message": "must have required property 'import_playbook'", + "params": { + "missingProperty": "import_playbook" + }, + "schemaPath": "#/oneOf/1/required" + }, + { + "instancePath": "/0", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/oneOf" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "hosts" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "gather_facts" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0", + "keyword": "additionalProperties", + "message": "must NOT have additional properties", + "params": { + "additionalProperty": "tasks" + }, + "schemaPath": "#/additionalProperties" + }, + { + "instancePath": "/0/gather_facts", + "keyword": "type", + "message": "must be boolean", + "params": { + "type": "boolean" + }, + "schemaPath": "#/properties/gather_facts/type" + }, + { + "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/gather_facts.yml", + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_facts': 'non', 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas", + "has_sub_errors": true, + "best_match": { + "path": "$[0]", + "message": "'gather_facts', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + "sub_errors": [ + { + "path": "$[0]", + "message": "'gather_facts', 'hosts', 'tasks' do not match any of the regexes: '^(ansible\\\\.builtin\\\\.)?import_playbook$', 'name', 'tags', 'vars'" + }, + { + "path": "$[0]", + "message": "{'hosts': 'localhost', 'gather_facts': 'non', 'tasks': [{'ansible.builtin.debug': {'msg': 'foo'}}]} is not valid under any of the given schemas" + }, + { + "path": "$[0]", + "message": "'ansible.builtin.import_playbook' is a required property" + }, + { + "path": "$[0]", + "message": "'import_playbook' is a required property" + }, + { + "path": "$[0].gather_facts", + "message": "'non' is not of type 'boolean'" + } + ] + } + ] +} +``` diff --git a/test/playbooks/gather_facts.yml b/test/playbooks/gather_facts.yml new file mode 100644 index 00000000..598188d6 --- /dev/null +++ b/test/playbooks/gather_facts.yml @@ -0,0 +1,6 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - ansible.builtin.debug: + msg: foo