On Thu, Sep 11, 2014 at 3:03 PM, Ches Martin <c...@nausicaamedia.com> wrote:

> Hi folks,
>
> I've been trying to come up with a solution to what essentially boils down
> to this:
>
> Say I'm writing, or simply using, a role which depends on a host var being
> set for all targeted hosts. An example is ZooKeeper, where each member of
> an ensemble needs a unique ID configured, and needs to enumerate all the
> other members in its config file (common for host in groups / hostvars
> pattern). I'd like to achieve this with an EC2 tag on each host, but say
> that the role already references a specific hostvar name (which naturally
> isn't ec2_tag_the_key_name_i_want).
>
> Can anyone suggest a programmatic way to map values to a particular host
> var name during a run? set_fact only appears applicable to the context of
> a single host as it executes a run (a with_items: groups[foo] loop does
> not work). I don't particularly want to juggle names in DNS for these hosts
> in order to use named files in host_vars.
>

I'm somewhat unclear on this one as the playbook parts and the dynamic
inventory parts are different things.

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.

(set_fact looping over a with_items doesn't allow you to set vars for other
hosts, true, it just makes the value of "item" be different in each
iteration of the loop is all)

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!
>
> Regards,
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1a3d5eff-6802-4541-98ba-29c42f1f73fd%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1a3d5eff-6802-4541-98ba-29c42f1f73fd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgwvggSPpE8WB_io6-PkEg%3DbNnNEBNyQDm6719med5GTOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to