mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Ensure we don't overwrite roles from include/import_role when loading the play (#47512)
* Ensure we don't overwrite roles from include/import_role when loading the play. Fixes #47454 * Add changelog fragment
This commit is contained in:
parent
e1c2dd383a
commit
d5e4f37ca0
5 changed files with 19 additions and 1 deletions
2
changelogs/fragments/no-overwrite-roles.yaml
Normal file
2
changelogs/fragments/no-overwrite-roles.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- roles - Ensure that we don't overwrite roles that have been registered (from imports) while parsing roles under the roles header (https://github.com/ansible/ansible/issues/47454)
|
|
@ -195,7 +195,12 @@ class Play(Base, Taggable, Become):
|
||||||
roles = []
|
roles = []
|
||||||
for ri in role_includes:
|
for ri in role_includes:
|
||||||
roles.append(Role.load(ri, play=self))
|
roles.append(Role.load(ri, play=self))
|
||||||
return roles
|
|
||||||
|
return self._extend_value(
|
||||||
|
self.roles,
|
||||||
|
roles,
|
||||||
|
prepend=True
|
||||||
|
)
|
||||||
|
|
||||||
def _load_vars_prompt(self, attr, ds):
|
def _load_vars_prompt(self, attr, ds):
|
||||||
new_ds = preprocess_vars(ds)
|
new_ds = preprocess_vars(ds)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
roles:
|
||||||
|
- call_import
|
|
@ -0,0 +1,6 @@
|
||||||
|
- import_role:
|
||||||
|
name: regular
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- regular_defaults_var is defined
|
|
@ -82,3 +82,4 @@ test "$(grep -c '"item=foo"' test_include_dupe_loop.out)" = 3
|
||||||
|
|
||||||
ansible-playbook public_exposure/playbook.yml -i ../../inventory "$@"
|
ansible-playbook public_exposure/playbook.yml -i ../../inventory "$@"
|
||||||
ansible-playbook public_exposure/no_bleeding.yml -i ../../inventory "$@"
|
ansible-playbook public_exposure/no_bleeding.yml -i ../../inventory "$@"
|
||||||
|
ansible-playbook public_exposure/no_overwrite_roles.yml -i ../../inventory "$@"
|
||||||
|
|
Loading…
Reference in a new issue