Use the computed role name instead of 'role'. Fixes #38838 (#39516)

pull/39530/head
Matt Martz 6 years ago committed by GitHub
parent 5f9b7046ed
commit 240b060c02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -160,7 +160,7 @@ class IncludedFile:
from_key = from_arg.replace('_from', '')
new_task._from_files[from_key] = templar.template(include_variables[from_arg])
inc_file = IncludedFile("role", include_variables, new_task, is_role=True)
inc_file = IncludedFile(role_name, include_variables, new_task, is_role=True)
try:
pos = included_files.index(inc_file)

@ -1,6 +1,6 @@
[local]
testhost ansible_ssh_host=127.0.0.1 ansible_connection=local host_var_role_name=role3
testhost2 ansible_ssh_host=127.0.0.1 ansible_connection=local
testhost2 ansible_ssh_host=127.0.0.1 ansible_connection=local host_var_role_name=role2
# For testing delegate_to
testhost3 ansible_ssh_host=127.0.0.3
testhost4 ansible_ssh_host=127.0.0.4

@ -1,5 +1,5 @@
- name: Test include_role
hosts: testhost
hosts: testhost,testhost2
vars:
run_role: yes
@ -85,10 +85,27 @@
include_role:
name: "{{ role_name }}"
- name: wipe role results
set_fact:
_role2_result: ~
_role3_result: ~
- name: Test using a host variable for role name
include_role:
name: "{{ host_var_role_name }}"
- name: assert that host varible for role name calls 2 diff roles
assert:
that:
- _role2_result is not none
when: inventory_hostname == 'testhost2'
- name: assert that host varible for role name calls 2 diff roles
assert:
that:
- _role3_result is not none
when: inventory_hostname == 'testhost'
- name: Pass variable to role
include_role:
name: role1

Loading…
Cancel
Save