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>
(cherry picked from commit 73369f53af)
pull/85403/head
Matt Davis 5 months ago committed by Matt Clay
parent 9a3288f8c4
commit a37df1a94a

@ -34,7 +34,6 @@ from ansible import constants as C
class PlaybookInclude(Base, Conditional, Taggable):
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

@ -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
- 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 }}"

Loading…
Cancel
Save