diff --git a/src/ansiblelint/schemas/ansible.json b/src/ansiblelint/schemas/ansible.json index 94846d0525..f16abf1e4e 100644 --- a/src/ansiblelint/schemas/ansible.json +++ b/src/ansiblelint/schemas/ansible.json @@ -348,8 +348,8 @@ "type": "boolean" }, "gather_facts": { - "title": "Gather Facts", - "type": "boolean" + "$ref": "#/$defs/templated-boolean", + "title": "Gather Facts" }, "gather_subset": { "items": { diff --git a/src/ansiblelint/schemas/playbook.json b/src/ansiblelint/schemas/playbook.json index 983033f820..ddf839b33d 100644 --- a/src/ansiblelint/schemas/playbook.json +++ b/src/ansiblelint/schemas/playbook.json @@ -363,8 +363,8 @@ "type": "boolean" }, "gather_facts": { - "title": "Gather Facts", - "type": "boolean" + "$ref": "#/$defs/templated-boolean", + "title": "Gather Facts" }, "gather_subset": { "items": { diff --git a/test/schemas/negative_test/playbooks/gather_facts.yml.md b/test/schemas/negative_test/playbooks/gather_facts.yml.md index 0eb3a4ba16..740daba330 100644 --- a/test/schemas/negative_test/playbooks/gather_facts.yml.md +++ b/test/schemas/negative_test/playbooks/gather_facts.yml.md @@ -63,7 +63,25 @@ "params": { "type": "boolean" }, - "schemaPath": "#/properties/gather_facts/type" + "schemaPath": "#/oneOf/0/type" + }, + { + "instancePath": "/0/gather_facts", + "keyword": "pattern", + "message": "must match pattern \"^\\{[\\{%](.|[\r\n])*[\\}%]\\}$\"", + "params": { + "pattern": "^\\{[\\{%](.|[\r\n])*[\\}%]\\}$" + }, + "schemaPath": "#/$defs/full-jinja/pattern" + }, + { + "instancePath": "/0/gather_facts", + "keyword": "oneOf", + "message": "must match exactly one schema in oneOf", + "params": { + "passingSchemas": null + }, + "schemaPath": "#/oneOf" }, { "instancePath": "/0", @@ -111,9 +129,17 @@ stdout: "path": "$[0]", "message": "'import_playbook' is a required property" }, + { + "path": "$[0].gather_facts", + "message": "'non' is not valid under any of the given schemas" + }, { "path": "$[0].gather_facts", "message": "'non' is not of type 'boolean'" + }, + { + "path": "$[0].gather_facts", + "message": "'non' does not match '^\\\\{[\\\\{%](.|[\\r\\n])*[\\\\}%]\\\\}$'" } ] } diff --git a/test/schemas/test/playbooks/gather_facts.yml b/test/schemas/test/playbooks/gather_facts.yml index 598188d6c2..bdba79023e 100644 --- a/test/schemas/test/playbooks/gather_facts.yml +++ b/test/schemas/test/playbooks/gather_facts.yml @@ -4,3 +4,9 @@ tasks: - ansible.builtin.debug: msg: foo + +- hosts: localhost + gather_facts: "{{ facts_var_bool | default(false) }}" + tasks: + - ansible.builtin.debug: + msg: bar