"is that I effectively want to assign/alias zookeeper_myid =
ec2_tag_zookeeper_id andzookeeper_bind_address = ec2_private_ip_address for
each host in the group"

Are you saying you wish to add them to another group?

The add_host module is good for that.



On Fri, Sep 12, 2014 at 9:57 AM, Michael Peters <[email protected]>
wrote:

> You could modify your dynamic inventory. I think in the past it's been
> said that the ec2.py, etc are starting points for your own dynamic
> inventory scripts. This way you can do what you want with your
> ec2_tag_* variables and makes it easier when part of your
> infrastructure isn't even on EC2.
>
> On Fri, Sep 12, 2014 at 4:08 AM, Ches Martin <[email protected]>
> wrote:
> > 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.
>
> --
> 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/CAJQqANec96Y1gnV7QQu_Sx8hhruZUs5Wk-Z%2BzRponLvO%3DJadkg%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BnsWgxmcGwW8_E%3DPLv9gfP%3D9rCpaYAPGa0JCXMmRGrLs7_BnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to