mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Discover .yml and .yaml files
Allow for 'playbook_extension' to be either a string or a tuple and change the default behavior to discover both.
This commit is contained in:
parent
2b364c92e6
commit
1207030427
1 changed files with 4 additions and 6 deletions
|
@ -502,7 +502,7 @@ def discover_playbooks(
|
|||
List of paths to discover playbooks from.
|
||||
|
||||
:param playbook_extension:
|
||||
File extension of playbooks file to search for. Default: "yml"
|
||||
File extension(s) of playbook files to search for, can be a string or tuple of strings. Default: (".yml", ".yaml")
|
||||
|
||||
:param hosts_filename:
|
||||
Filename of custom playbook inventory to search for. Default: "hosts"
|
||||
|
@ -533,7 +533,7 @@ def discover_playbooks(
|
|||
)
|
||||
|
||||
if not playbook_extension:
|
||||
playbook_extension = "yml"
|
||||
playbook_extension = (".yml", ".yaml")
|
||||
if not hosts_filename:
|
||||
hosts_filename = "hosts"
|
||||
|
||||
|
@ -573,7 +573,7 @@ def _explore_path(path, playbook_extension, hosts_filename, syntax_check):
|
|||
# Check files in the given path
|
||||
for _f in os.listdir(path):
|
||||
_path = os.path.join(path, _f)
|
||||
if os.path.isfile(_path) and _path.endswith("." + playbook_extension):
|
||||
if os.path.isfile(_path) and _path.endswith(playbook_extension):
|
||||
ret[_f] = {"fullpath": _path}
|
||||
# Check for custom inventory file
|
||||
if os.path.isfile(os.path.join(path, hosts_filename)):
|
||||
|
@ -584,9 +584,7 @@ def _explore_path(path, playbook_extension, hosts_filename, syntax_check):
|
|||
# Check files in the 1st level of subdirectories
|
||||
for _f2 in os.listdir(_path):
|
||||
_path2 = os.path.join(_path, _f2)
|
||||
if os.path.isfile(_path2) and _path2.endswith(
|
||||
"." + playbook_extension
|
||||
):
|
||||
if os.path.isfile(_path2) and _path2.endswith(playbook_extension):
|
||||
ret[os.path.join(_f, _f2)] = {"fullpath": _path2}
|
||||
# Check for custom inventory file
|
||||
if os.path.isfile(os.path.join(_path, hosts_filename)):
|
||||
|
|
Loading…
Add table
Reference in a new issue