[stable-2.7] Support .yaml extension for meta file (#46505)

(cherry picked from commit e4cadddd70)
This commit is contained in:
Jiri Tyr 2018-11-09 22:29:06 +00:00 committed by Toshio Kuratomi
parent 093ab2170d
commit 476673f3e4
2 changed files with 25 additions and 21 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ansible-galaxy - support yaml extension for meta file (https://github.com/ansible/ansible/pull/46505)

View file

@ -46,7 +46,7 @@ except ImportError:
class GalaxyRole(object):
SUPPORTED_SCMS = set(['git', 'hg'])
META_MAIN = os.path.join('meta', 'main.yml')
META_MAIN = (os.path.join('meta', 'main.yml'), os.path.join('meta', 'main.yaml'))
META_INSTALL = os.path.join('meta', '.galaxy_install_info')
ROLE_DIRS = ('defaults', 'files', 'handlers', 'meta', 'tasks', 'templates', 'vars', 'tests')
@ -96,7 +96,8 @@ class GalaxyRole(object):
Returns role metadata
"""
if self._metadata is None:
meta_path = os.path.join(self.path, self.META_MAIN)
for meta_main in self.META_MAIN:
meta_path = os.path.join(self.path, meta_main)
if os.path.isfile(meta_path):
try:
f = open(meta_path, 'r')
@ -268,7 +269,8 @@ class GalaxyRole(object):
members = role_tar_file.getmembers()
# next find the metadata file
for member in members:
if self.META_MAIN in member.name:
for meta_main in self.META_MAIN:
if meta_main in member.name:
# Look for parent of meta/main.yml
# Due to possibility of sub roles each containing meta/main.yml
# look for shortest length parent