Fix pb subs collapse (#74301)
* fix subdir parsing for plays fixes #74283 Co-authored-by: Nikolaos Kakouros <nkak@kth.se>
This commit is contained in:
parent
a3e7cf0110
commit
6418f368e3
7 changed files with 41 additions and 0 deletions
2
changelogs/fragments/coll_pb_subdir_fixes.yml
Normal file
2
changelogs/fragments/coll_pb_subdir_fixes.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- playbook loaded from collection subdir now does not ignore subdirs.
|
|
@ -891,6 +891,12 @@ def _get_collection_playbook_path(playbook):
|
|||
|
||||
if pkg:
|
||||
cpath = os.path.join(sys.modules[acr.n_python_collection_package_name].__file__.replace('__synthetic__', 'playbooks'))
|
||||
|
||||
if acr.subdirs:
|
||||
paths = [to_native(x) for x in acr.subdirs.split(u'.')]
|
||||
paths.insert(0, cpath)
|
||||
cpath = os.path.join(*paths)
|
||||
|
||||
path = os.path.join(cpath, to_native(acr.resource))
|
||||
if os.path.exists(to_bytes(path)):
|
||||
return acr.resource, path, acr.collection
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- set_fact: play='tldr'
|
|
@ -0,0 +1,4 @@
|
|||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- set_fact: play_type='in type subdir'
|
|
@ -0,0 +1,4 @@
|
|||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- set_fact: play_type_subtype='in subtype subdir'
|
|
@ -1,2 +1,17 @@
|
|||
- import_playbook: testns.testcoll.default_collection_playbook.yml
|
||||
- import_playbook: testns.testcoll.default_collection_playbook
|
||||
|
||||
# test subdirs
|
||||
- import_playbook: "testns.testcoll.play"
|
||||
- import_playbook: "testns.testcoll.type.play"
|
||||
- import_playbook: "testns.testcoll.type.subtype.play"
|
||||
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: check values from imports
|
||||
assert:
|
||||
that:
|
||||
- play is defined
|
||||
- play_type is defined
|
||||
- play_type_subtype is defined
|
||||
|
|
|
@ -891,6 +891,12 @@ def _get_collection_playbook_path(playbook):
|
|||
|
||||
if pkg:
|
||||
cpath = os.path.join(sys.modules[acr.n_python_collection_package_name].__file__.replace('__synthetic__', 'playbooks'))
|
||||
|
||||
if acr.subdirs:
|
||||
paths = [to_native(x) for x in acr.subdirs.split(u'.')]
|
||||
paths.insert(0, cpath)
|
||||
cpath = os.path.join(*paths)
|
||||
|
||||
path = os.path.join(cpath, to_native(acr.resource))
|
||||
if os.path.exists(to_bytes(path)):
|
||||
return acr.resource, path, acr.collection
|
||||
|
|
Loading…
Reference in a new issue