Hi,

I have a dynamic inventory of ec2 hosts that have tags to declare how those 
should be provisioned. My use-case is as follows:

- 1 EC2 host has a tag "tomcat" and "use"
- 2 EC2 hosts have a tag "mysql"
  one of them has a tag "use"
  on of them has a tag "dont-use"

I'd like to provision only the "use" hosts. The challenge is that the 
tomcat host needs a variable with the ip address of the mysql host. I 
currently have a playbook that matches on all hosts in the "use" group. 
Then I apply the roles using when: 'mysql' in group_names, 'tomcat' 
respectively.

roles:
- {
   role: 'my_tomcat_role',
   mysql_ip: "WHAT TO PUT HERE?",
   when: "'tomcat' in group_names",
   sudo: yes
  }

I have played around with various techniques. Eg. try to dynamically 
group_by in the pre tasks to create temp groups of all hosts that have been 
matched by the playbook but that does not work, because group_by seems to 
implicitly only run_once and thus can not use the group_names:

  - group_by: key=current_{{ item }}
    with_items: "{{ group_names }}"

The above does not work.

I can not register variables because those will only be available per host, 
so that does not work either because I don't know the hostname of the 
mysql-tagged instance.

Any ideas? Maybe this is a feature request to allow to select 
hostvars/hosts by the same pattern syntax that is available in the playbook 
hosts: directive.

Thanks,
Nicolas

-- 
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/cdcefa52-c1c7-4f92-b412-f2087352b8e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to