A possible solution if I can't expand the lists into one list is to define
a different group of hosts specifically for the application. Though that
seems messier
On Thursday, 18 December 2014 11:45:35 UTC, James Morgan wrote:
>
> Hi,
>
> I have a list of groups
>
> admin:
> groups: ['group-boapp-layout-A', 'group-boapp-layout-B']
>
> Each of these groups has a number of hosts as defined in the inventory
>
> (note that this info needs to be global as opposed to per
> group_vars/group-boapp-layout-A.yml so that it can be accessed by other
> groups)
>
> [group-boapp-layout-A]
> ec2-test-boapp01
> ec2-test-boapp02
>
> [group-boapp-layout-B]
> ec2-test-boapp03
> ec2-test-boapp04
>
> [tier-boapp:children]
> group-boapp-layout-A
> group-boapp-layout-B
>
> GROUPS Variables ("groups"):
> --------------------------------
> {
> "all": [
> "ec2-test-boapp03",
> "ec2-test-boapp04",
> "ec2-test-boapp01",
> "ec2-test-boapp02"
> ],
> "group-boapp-layout-A": [
> "ec2-test-boapp01",
> "ec2-test-boapp02"
> ],
> "group-boapp-layout-B": [
> "ec2-test-boapp03",
> "ec2-test-boapp04"
> ],
>
> I would like to get a list of hosts that admin should live on (union of
> group-boapp-layout-A
> and group-boapp-layout-B)
>
> =>
> *['ec2-test-boapp01','ec2-test-boapp02','ec2-test-boapp03','ec2-test-boapp04']*
>
>
> I have tried to use *with_flattened *though I only end up with the hosts
> from the last group
>
> set_fact:
> hosts: "{{ groups[item] }}"
> with_flattened: admin.groups
>
> - debug: msg="{{ app_name }} hosts = {{ hosts }}"
>
> -----------------------------------
>
> ok: [ec2-test-boapp01] => {
> "msg": "admin hosts = ['ec2-test-boapp03', 'ec2-test-boapp04']"
> }
> ok: [ec2-test-boapp03] => {
> "msg": "admin hosts = ['ec2-test-boapp03', 'ec2-test-boapp04']"
> }
> ok: [ec2-test-boapp02] => {
> "msg": "admin hosts = ['ec2-test-boapp03', 'ec2-test-boapp04']"
> }
> ok: [ec2-test-boapp04] => {
> "msg": "admin hosts = ['ec2-test-boapp03', 'ec2-test-boapp04']"
> }
>
>
> This was working with v1.7.x I am now using
>
> ansible-playbook 1.8.1
>
>
> I'd appreciate any input or if there is a better way to do this.
>
> Thanks
>
> James
>
>
>
>
>
>
>
>
>
--
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/6ef3aa0f-2dab-4392-8f64-5d69a3d23765%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.