mirror of
https://github.com/ansible/ansible.git
synced 2026-08-02 16:12:06 +02:00
Remove redundant vars FA on PlaybookInclude (#85395)
* The redundant FA declaration was not static, which broke a number of automatic validation behaviors. * Added tests to assert deferred validation and lack of templating on `import_playbook.vars`. Co-authored-by: Matt Clay <matt@mystile.com>
This commit is contained in:
@@ -34,7 +34,6 @@ from ansible import constants as C
|
|||||||
class PlaybookInclude(Base, Conditional, Taggable):
|
class PlaybookInclude(Base, Conditional, Taggable):
|
||||||
|
|
||||||
import_playbook = NonInheritableFieldAttribute(isa='string', required=True)
|
import_playbook = NonInheritableFieldAttribute(isa='string', required=True)
|
||||||
vars_val = NonInheritableFieldAttribute(isa='dict', default=dict, alias='vars')
|
|
||||||
|
|
||||||
_post_validate_object = True # manually post_validate to get free arg validation/coercion
|
_post_validate_object = True # manually post_validate to get free arg validation/coercion
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- name: Verify an imported playbook can see a var it was given
|
||||||
|
assert:
|
||||||
|
that: pb_var == 'hello'
|
||||||
@@ -20,3 +20,15 @@
|
|||||||
|
|
||||||
# https://github.com/ansible/ansible/issues/59548
|
# https://github.com/ansible/ansible/issues/59548
|
||||||
- import_playbook: sub_playbook/sub_playbook.yml
|
- import_playbook: sub_playbook/sub_playbook.yml
|
||||||
|
|
||||||
|
- name: Use set_fact to declare a variable
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- set_fact:
|
||||||
|
a_var_from_set_fact: hello
|
||||||
|
|
||||||
|
- name: Verify vars for import_playbook are not templated too early
|
||||||
|
import_playbook: playbook_using_a_var.yml
|
||||||
|
vars:
|
||||||
|
pb_var: "{{ a_var_from_set_fact }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user