But renaming the variables in either one would cause problems for
existing playbooks, so it would need to keep the old names around for
existing uses. This could lead to some confusion as the hostvars will
be polluted with duplicate entries and there's no real way to
encourage people to use the "right" names for the vars.
IMO the ec2.py script should be changed to match the ec2_facts module
as the latter is an official part of ansible and the former is often
referred to as a "starting point" for your own inventory scripts.
--
IMO the ec2.py script should be changed to match the ec2_facts module
as the latter is an official part of ansible and the former is often
referred to as a "starting point" for your own inventory scripts.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJQqANdqu7TkyX3Vwsu7fND36r9djjHmvGa1r690yu6CP8sJUw%40mail.gmail.com.
- It seems best if ec2_facts conform to inventory, rather than vice versa
It might be useful to call out specific examples other than just the tags being missing, such as which variable names you don't see standardized.
These variables are pulled out of a boto.ec2.instance object. There is a lack of
consistency with variable spellings (camelCase and underscores) since this
just loops through all variables the object exposes. It is preferred to use the
ones with underscores when multiple exist.
- We don't want to break anyone, but this may be unavoidable. As such, I'd suggest a return_mode='v1', defaulting to something like 'v2', and making sure common code from module_utils is used so that functions from the inventory script return the same data
- I don't understand some statements in the above, like I can't parse " ansible_ec2_public_hostname is the answer, and that ec2_facts play." what that means.
Thanks Michael, that's helpful, especially about giving favor to the inventory plugin. I'll try to drop in IRC when I can start hacking on it (probably a week from now), I'm sure I'll have some questions about internals like what you're saying about module_utils, but a few remarks:
On Sunday, September 14, 2014 8:35:16 PM UTC+7, Michael DeHaan wrote:- It seems best if ec2_facts conform to inventory, rather than vice versaIt might be useful to call out specific examples other than just the tags being missing, such as which variable names you don't see standardized.Well... basically all of them: ec2_facts uses ansible_ec2_ as a prefix, the inventory plugin uses ec2_. It's not only prefix, the public hostname thing is an example, which I'll get to in a sec. When I'm sitting at a working environment I'll gist some censored output from ec2.py --list and ansible -m ec2_facts for sake of reference in discussion. The inventory plugin has this comment FWIW:These variables are pulled out of a boto.ec2.instance object. There is a lack of
consistency with variable spellings (camelCase and underscores) since this
just loops through all variables the object exposes. It is preferred to use the
ones with underscores when multiple exist.
Setting aside the issue of which names are kept and backwards compat for now (I think it's pretty clear that we'll want to preserve it, for awhile at least), would you prefer to standardize on ansible_ec2_ as var prefix?
My team favors the inventory plugin most of the time but cases like this trip them up. Particularly because we use tags a good deal, we've become conditioned to first looking to ec2.py --list to find EC2 vars to use, hence there's a bunch of ec2_public_dns_name and its ilk used throughout our playbooks. People are confused when they write a provisioning playbook and these fail. I've had to explain this discrepancy multiple times.