On Friday, September 12, 2014 6:31:37 AM UTC+7, Michael DeHaan wrote:
>
> Can you elaborate on what "map values to a particular host var name" would
> mean?
>
> If I may guess at the question, group_vars/<groupname> does in fact work
> with dynamic groups, if you want everything in ec2_tag_the_key_name_I_want
> to get a value like x: 42.
>
<snip>
> Let me know more info and I can perhaps get a bit closer, but I *think*
> group_vars is what you want.
>
Thanks for your help Michael.
group_vars can actually solve *part* of the problem in a kludgy way, I'm
not sure if this is what you had in mind. Let me elaborate the ZooKeeper
example, it's concrete for me, though there are some other cases where I
want essentially the same thing. Here's the snippet of a zoo.cfg template
for enumerating cluster members, pretty standard stuff:
{% for host in groups[zookeeper_ensemble_group] %}
server.{{ hostvars[host].zookeeper_myid }}={{
hostvars[host].zookeeper_bind_address
}}:2888:3888
{% endfor %}
So, what I meant by "map values to a particular host var name" is that I
effectively want to assign/alias zookeeper_myid = ec2_tag_zookeeper_id and
zookeeper_bind_address
= ec2_private_ip_address for each host in the group, before this zookeeper
role runs. I was hoping for a way to do this without having to modify an
upstream role, or in writing my own shareable roles to not have them
coupled to choices of a particular inventory source, so users can simply
consistently override a sensibly-named variable.
After you mentioned it, group_vars does partly help, in a very redundant
way via the dynamic groups that include tag values along with key:
---
# group_vars/tag_zoo_keeper_id_1
zookeeper_myid: 1
# This of course doesn't work, we can't use dynamic values here
zookeeper_bind_address: '{{ ec2_private_ip_address }}'
That achieves the alias for the zookeeper_myid var, at the expense of
maintaining three things: an EC2 tag, the group_vars file name, and the
static value in the file. And doesn't help with the dynamic address, so not
really workable :-\
Maybe you meant something different, or does the explanation help to spot
any alternatives?
Thanks again!
-Ches
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ea3dfe05-e0d5-4653-8943-d5f8cceb7f8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.