Skip to content

Commit

Permalink
lib/hardware: introduce ANSIBLE_PLAYBOOK_EXTRA_ARGS
Browse files Browse the repository at this point in the history
This change makes it possible to add extra variables
for ansible-playbook calls, this is usefull when one
want to pass multiple --extra-vars arguments in the
native format giving user a choice to use json, name=value
pairs or path to yaml/json files.

Signed-off-by: Kyr Shatskyy <[email protected]>
  • Loading branch information
Kyr Shatskyy committed Oct 29, 2020
1 parent 2f25cf6 commit 0f6e78b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ _remove_workspace = true
# Allow passing extra variables to Ansible (below as JSON)
# example: export ROOKCHECK_ANSIBLE_EXTRA_VARS='{"extra_repos":{"storage_latest": "http://myextra.repo/"}}'
ansible_extra_vars = ""

# Pass extra arguments to ansible-playbook, for example:
# ROOKCHECK_ANSIBLE_PLAYBOOK_EXTRA_ARGS='-e @somefile.yaml -f 1 -vvv'
ansible_playbook_extra_args = ""
4 changes: 3 additions & 1 deletion tests/lib/hardware/hardware_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ def ansible_run_playbook(self, playbook: str,
else:
extra_vars_param = ""

extra_args = settings.get('ANSIBLE_PLAYBOOK_EXTRA_ARGS', '')

logger.info(f'Running playbook {path} ({limit})')
self.workspace.execute(
f"ansible-playbook -i {self._ansible_inventory_dir} "
f"{limit} {extra_vars_param} {path}",
f"{limit} {extra_vars_param} {extra_args} {path}",
logger_name=f"ansible {playbook}")

def _ansible_create_inventory(self):
Expand Down

0 comments on commit 0f6e78b

Please sign in to comment.