add custom modules auto-detection

This commit is contained in:
Robert Kaussow 2020-06-27 22:33:51 +02:00
parent bec9789649
commit d7dac43a72
Signed by: xoxys
GPG Key ID: 65362AE74AF98B61
3 changed files with 19 additions and 9 deletions

View File

@ -1,6 +1,2 @@
* BUGFIX
* fix typo in argparse description
* INTERNAL
* add markdown linting to CI (markdownlint-cli)
* add spellchecking to CI (spellcheck-cli)
* add broken link check to CI (broken-link-checker)
* ENHANCEMENT
* add custom modules auto-detection

View File

@ -88,6 +88,19 @@ class Settings(object):
if cli_options and self._validate(cli_options):
anyconfig.merge(defaults, cli_options, ac_merge=anyconfig.MS_DICTS)
library = os.path.relpath(os.path.normpath(os.path.join(os.getcwd(), "library")))
autodetect = []
if os.path.exists(library):
autodetect = [
os.path.splitext(f)[0]
for f in os.listdir(library)
if os.path.isfile(os.path.join(library, f)) and not f.startswith(".")
]
for f in autodetect:
if f not in defaults["ansible"]["custom_modules"]:
defaults["ansible"]["custom_modules"].append(f)
return defaults
def _get_defaults(self):

View File

@ -8,9 +8,10 @@ title: Default settings
{{< highlight YAML "linenos=table" >}}
---
ansible:
# Add the name of used custom Ansible modules.
# Otherwise ansible-later can't detect unknown modules
# and will through an error.
# Add the name of used custom Ansible modules. Otherwise ansible-later
# can't detect unknown modules and will through an error.
# Modules which are bundled with the role and placed in a './library'
# directory will be auto-detected and don't need to be added to this list.
custom_modules: []
# Settings for variable formatting rule (ANSIBLE0004)
double-braces: