Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ANSIBLE_PLAYBOOK_EXTRA_ARGS #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I would prefer to not add another variable that overlaps with ANSIBLE_EXTRA_ARGS
  • If we go that way, it needs to be documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any serious issues with overlaping, it gives user an option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing and everything you can do with ANSIBLE_PLAYBOOK_EXTRA_ARGS can be done already with ANSIBLE_EXTRA_ARGS. So what's the benefit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There two advantages:

  1. allows multiple usage of --extra-vars, so you can, for example, use more than one json file with properties without prio combining it in one.
  2. allows to provide other options to ansible-playbook rather than --extra-vars, see example in the doc (btw I added it by your request).


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