mirror of https://github.com/ansible/ansible.git
import_role - support templating _from_files with --extra-vars (#75269)
* Support templating _from_files with --extra-vars for imported roles * Add tests for templating the filenames for import_role, import_playbook, and import_tasks * Add documentation Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com> Co-authored-by: Martin Krizek <martin.krizek@gmail.com>pull/71190/merge
parent
d36116ef1c
commit
db3e8f2c1c
@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- import_role - Template tasks_from, vars_from, defaults_from, and handlers_from with --extra-vars (https://github.com/ansible/ansible/issues/69097).
|
@ -0,0 +1,47 @@
|
||||
- name: test templating import_playbook with extra vars
|
||||
import_playbook: "{{ pb }}"
|
||||
|
||||
- name: test templating import_playbook with vars
|
||||
import_playbook: "{{ test_var }}"
|
||||
vars:
|
||||
test_var: validate_templated_playbook.yml
|
||||
|
||||
- name: test templating import_tasks
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
vars:
|
||||
play_var: validate_templated_tasks.yml
|
||||
tasks:
|
||||
- name: test templating import_tasks with play vars
|
||||
import_tasks: "{{ play_var }}"
|
||||
|
||||
- name: test templating import_tasks with task vars
|
||||
import_tasks: "{{ task_var }}"
|
||||
vars:
|
||||
task_var: validate_templated_tasks.yml
|
||||
|
||||
- name: test templating import_tasks with extra vars
|
||||
import_tasks: "{{ tasks }}"
|
||||
|
||||
- name: test templating import_role from_files
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
vars:
|
||||
play_var: templated.yml
|
||||
tasks:
|
||||
- name: test templating import_role tasks_from with play vars
|
||||
import_role:
|
||||
name: role1
|
||||
tasks_from: "{{ play_var }}"
|
||||
|
||||
- name: test templating import_role tasks_from with task vars
|
||||
import_role:
|
||||
name: role1
|
||||
tasks_from: "{{ task_var }}"
|
||||
vars:
|
||||
task_var: templated.yml
|
||||
|
||||
- name: test templating import_role tasks_from with extra vars
|
||||
import_role:
|
||||
name: role1
|
||||
tasks_from: "{{ tasks_from }}"
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- debug: msg="In imported playbook"
|
@ -0,0 +1 @@
|
||||
- debug: msg="In imported tasks"
|
@ -0,0 +1 @@
|
||||
- debug: msg="In imported role"
|
Loading…
Reference in New Issue