-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: master
Are you sure you want to change the base?
Conversation
tests/lib/hardware/hardware_base.py
Outdated
# Supplied extra_vars from settings always take precedence | ||
if settings.ANSIBLE_EXTRA_VARS: | ||
extra_vars.update(json.loads(settings.ANSIBLE_EXTRA_VARS)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should change the method parameter extra_vars
to just expect a string which can either be json or a string starting with @
or even something like version=1.23.45
(see https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#defining-variables-at-runtime fro all possibilities). Then we could just do --extra-vars {extra_vars}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should decouple the method parameter extra_vars
, from the settings variable ANSIBLE_EXTRA_VARS
.
Because we can apply multiple --extra-vars
we should just supply both (--extra-vars {extra_vars} --extra-vars {settings.ANSIBLE_EXTRA_VARS}
) giving both the option to be in any format supported by ansible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love you are discussing this here, but could you please merge this PR to unblock me, and create another PR to with your suggestion, I am happy you guys want to replicate all the features of ansible in rookcheck, but I don't like you force me to do this in this PR.
My intention in this patch was not to break existing functionality in rookcheck to not interfere someone else work.
Regarding @toabctl comment if you want to just have something like ROOKCHECK_ANSIBLE_EXTRA_VARS=--extra-vars {extra_vars}
, it would not go with this, it can be confusing, I would suggest to use ROOKCHECK_ANSIBLE_EXTRA_ARGS
for that purpose and we can drop the ROOKCHECK__ANSIBLE_EXTRA_VARS since it is useless.
Regardging @jhesketh comment in the context of rookcheck I don't see any advantage of using multipe --extra-vars when passing the parameters to ansible via tox|pytest, I would prefer to have a single file do not pack every parameter to the command line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love you are discussing this here, but could you please merge this PR to unblock me, and create another PR to with your suggestion, I am happy you guys want to replicate all the features of ansible in rookcheck, but I don't like you force me to do this in this PR.
Not looking to re-implement Ansible. My suggestions were for a simplifier and more complete solution.
My intention in this patch was not to break existing functionality in rookcheck to not interfere someone else work.
The suggested changes should not break existing functionality.
Regarding @toabctl comment if you want to just have something like
ROOKCHECK_ANSIBLE_EXTRA_VARS=--extra-vars {extra_vars}
, it would not go with this, it can be confusing, I would suggest to useROOKCHECK_ANSIBLE_EXTRA_ARGS
for that purpose and we can drop the ROOKCHECK__ANSIBLE_EXTRA_VARS since it is useless.Regardging @jhesketh comment in the context of rookcheck I don't see any advantage of using multipe --extra-vars when passing the parameters to ansible via tox|pytest, I would prefer to have a single file do not pack every parameter to the command line.
The multiple --extra-vars
isn't for having to pack each variable as a parameter. It is because we have extra vars coming from two places. 1) some tests and internals of rookcheck may need to overwrite variables at different times, and 2) the user may want to overwrite variables in configuration.
My suggestion simplifies the implementation by separating the two sources of vars, and passing them in directly giving both the test writer and the configuring user the option to use files, json, or otherwise (as supported by Ansible).
Hope that makes more sense, but let me know if not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention in this patch was not to break existing functionality in rookcheck to not int> > Regarding @toabctl comment if you want to just have something like
ROOKCHECK_ANSIBLE_EXTRA_VARS=--extra-vars {extra_vars}
, it would not go with this, it can be confusing, I would suggest to useROOKCHECK_ANSIBLE_EXTRA_ARGS
for that purpose and we can drop the ROOKCHECK__ANSIBLE_EXTRA_VARS since it is useless.
Regardging @jhesketh comment in the context of rookcheck I don't see any advantage of using multipe --extra-vars when passing the parameters to ansible via tox|pytest, I would prefer to have a single file do not pack every parameter to the command line.
erfere someone else work.
The suggested changes should not break existing functionality.
To be honest I don't understand the changes you suggest. Looking forward to review your upcoming PR.
The multiple
--extra-vars
isn't for having to pack each variable as a parameter. It is because we have extra vars coming from two places. 1) some tests and internals of rookcheck may need to overwrite variables at different times, and 2) the user may want to overwrite variables in configuration.
I didn't see that in the existing code, and what the examples say it packs json into the variable. This is why this PR appeared.
My suggestion simplifies the implementation by separating the two sources of vars, and passing them in directly giving both the test writer and the configuring user the option to use files, json, or otherwise (as supported by Ansible).
Hope that makes more sense, but let me know if not.
I understand the sense of original ansible-playbook options very well. What I do not understand is your suggestion, it would be easier if you provided code examples. Anyways we are discussing the code which is not created by me, I was not going to change it, and more the current PR revision does not even touch it.
I hope we merge it asap, so I do not need to cherry-pick it from branch to branch in order to use the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No (unless I'm missing something). My previous change updated the vars by loading in the settings as a python dict and updating them then passing a final version of the dict to Ansible by one --extra-vars
. #216 passes the settings as a second --extra-vars
when once applied will overwrite anything else in the same order of precedence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhesketh I might be wrong but after Tom updated his initial version of the PR it is not now.
f04029f
to
b0cf0a1
Compare
The jenkins failure is unrelated to the PR. |
@@ -159,10 +159,12 @@ def ansible_run_playbook(self, playbook: str, | |||
else: | |||
extra_vars_param = "" | |||
|
|||
extra_args = settings.get('ANSIBLE_PLAYBOOK_EXTRA_ARGS', '') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There two advantages:
- 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.
- allows to provide other options to ansible-playbook rather than --extra-vars, see example in the doc (btw I added it by your request).
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]>
b0cf0a1
to
0f6e78b
Compare
Does #216 satisfy your needs and supersede this PR? |
Thanks, I think it covers my needs, however I didn't test it, but it does not supersede current version of this PR, because the latter allow more than just passing --extra-vars. |
It is a little confusing, but it is talking about extra arguments to the |
No, it is not confusing, you are messing vars and args. The variables are internal things in ansible, arguments are the synonym for parameters for a program, same as options. |
Guys, I don't want to spend your time on this anylonger, if you're not okay with it, I close. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this, although I do have hesitations on not having too many settings in general.
@toabctl I'll leave this open for you to respond to the open comments.
I still don't see a benefit to have 2 options. So I would then like to have only this option (ANSIBLE_PLAYBOOK_EXTRA_ARGS) but feel free to merge..
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]