Now that (on the integration branch) we can represent variables on a per host basis (among other things), --extra-vars as a CLI option is overcomplicating things.
In case where I don’t remember how things work, code dies. Thus --extra-vars needs to go.
If you want to pass variables into a playbook, define them in the vars file or the playbook, or use vars_prompt to ask for them.
For instance if doing a release script, putting the release variable at the top of the playbook should be fine.
–Michael
--extra-vars was originally intended (on my part) as a way to pass
vars to the inventory script -- so losing it will be a big problem for
me, unless the inventory script has access to all the vars.
What’s the full explanation of the use case?
i.e. what does the playbook do and what are the actual args you are passing to the inventory script
and what is the logic of the inventory script?
vars can come from both the playbook and the inventory at the same time (these are merged) so I don’t yet
understand what this would be needed for.
Or to put it differently, there’s perhaps a better way to solve this?
I use extra-vars to pass a) a cobbler host and b) some filtering
criteria to the inventory script.
I would think you could just hard code the cobbler host in the script or make a configuration file for the inventory script in this case.
You may have to elaborate more on filtering criteria.
–Michael
I have a shell script that I execute like so:
play -H host1,host2 -L datacenter1 -s web,db ...and some other
uninteresting arguments.
This tells inventory to only return data for those hosts, locations,
and services. Some of this could be solved in other ways, but I'm not
sure it all could.
(The shell script invokes ansible-playboook with the data packed into
--extra-vars)
Ok, so…
To me, that sounds like you should be probably be defining and using groups, if web and db are what I think they are.
“web” “datacenter” and so forth, look like groups.
However, there’s an easy fix. Teach your external inventory script to pay attention to environment variables, and then you can set anything you want. Have your playbook wrapper script set the variable, and then have the external inventory script read it.
–Michael