Merge pull request #7 from matbu/master

Handle List or string playbook type
This commit is contained in:
mathieu bultel 2020-03-09 22:40:36 +01:00 committed by GitHub
commit 06892d8c65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,14 +29,21 @@ class Run(object):
def __init__(self): def __init__(self):
self.log = logging.getLogger(__name__ + ".Run") self.log = logging.getLogger(__name__ + ".Run")
def run_validations(self, playbook, inventory, def run_validations(self, playbook=[], inventory='localhost',
group=None, extra_vars=None, validations_dir=None, group=None, extra_vars=None, validations_dir=None,
validation_name=None, extra_env_var=None, validation_name=None, extra_env_vars=None,
ansible_cfg=None, quiet=True): ansible_cfg=None, quiet=True):
self.log = logging.getLogger(__name__ + ".run_validations") self.log = logging.getLogger(__name__ + ".run_validations")
playbooks = [] if isinstance(playbook, list):
playbooks = playbook
elif isinstance(playbook, str):
playbooks = []
playbooks.append(playbook)
else:
raise TypeError("Playbooks should be a List or a Str")
if group: if group:
self.log.debug('Getting the validations list by group') self.log.debug('Getting the validations list by group')
try: try:
@ -76,7 +83,7 @@ class Run(object):
output_callback='validation_json', output_callback='validation_json',
quiet=quiet, quiet=quiet,
extra_vars=extra_vars, extra_vars=extra_vars,
extra_env_variables=extra_env_var, extra_env_variables=extra_env_vars,
ansible_cfg=ansible_cfg, ansible_cfg=ansible_cfg,
gathering_policy='explicit') gathering_policy='explicit')
results.append({'validation': { results.append({'validation': {