Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Improve gather facts and subset support #326

Merged
merged 4 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dzdo
ededed
envlist
eoan
facter
fbba
fbca
fcba
Expand Down
30 changes: 29 additions & 1 deletion f/ansible-playbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 29 additions & 1 deletion f/ansible.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions negative_test/playbooks/gather_facts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- hosts: localhost
gather_facts: non
tasks:
- ansible.builtin.debug:
msg: foo
122 changes: 122 additions & 0 deletions negative_test/playbooks/gather_facts.yml.md
Original file line number Diff line number Diff line change
@@ -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'"
}
]
}
]
}
```
6 changes: 6 additions & 0 deletions negative_test/playbooks/gather_subset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- hosts: localhost
gather_subset: all
tasks:
- ansible.builtin.debug:
msg: foo
122 changes: 122 additions & 0 deletions negative_test/playbooks/gather_subset.yml.md
Original file line number Diff line number Diff line change
@@ -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'"
}
]
}
]
}
```
7 changes: 7 additions & 0 deletions negative_test/playbooks/gather_subset2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: localhost
gather_subset:
- invalid
tasks:
- ansible.builtin.debug:
msg: foo
Loading