Hi Brent , thanks for your reply. I was actually trying to avoid that as I
was looking to achieve it in a more dynamic way so I don't have to maintain
a static inventory of pools..
This is what I have tried but still not working :
# inventory :
[pool-a:vars]
pool=a
[pool-a]
server1
server2
server3
[pool-b:vars]
pool=b
[pool-b]
server4
server5
server6
# template.j2
{% for servers in groups['pool-{{ pool }}'] %}
server {{ hostvars[backend]['ansible_hostname'] }}
{% endfor %}
# playbook
template: src=front_config.j2 dest=/etc/front_config
fatal: [testing.example.net] => {'msg': "AnsibleUndefinedVariable: One or
more undefined variables: 'dict object' has no attribute 'pool-{{ pool
}}'", 'failed': True}
Any help ?
On Wednesday, May 20, 2015 at 12:04:06 AM UTC-4, Brent Langston wrote:
>
> What you describe is similar to a setup I've used in the past. We broke
> up this part of our inventory into "pools" which was determined by a fact
> set for the host.
>
> You could have poolA poolB and poolC, and db1, db2 and db3 respectively.
> poolA would connect to db1, poolB to db2, and poolC to db3.
>
> Today, we're using AWS, and the ec2.py inventory script. We carve up our
> inventory into (among other things) primary_role, secondary_role, and pool,
> so in your situation, unless db1, db2 and db3 are different enough that it
> makes sense to give them different secondary_roles, then just isolationg by
> pool should be easy.
>
> --------
> Brent
> --------
>
> On Tue, May 19, 2015 at 11:11 PM, Nicolas G <[email protected]
> <javascript:>> wrote:
>
>> Hi,
>>
>> We have a 2 tiers environment where the front-end servers connects to the
>> backend servers.
>>
>> As an example we have 30 application servers and 3 backend servers, let's
>> say every backend server should support up to 10 frontend servers. We need
>> Ansible to automatically setup the configuration so the load is shared :
>>
>> servers 1-10 should connect to db1
>> servers 11-20 should connect to db2
>> servers 21-30 should connect to db3
>>
>> The front-end servers doesn't need to be sequential, the number of
>> front-end can increase as the number of backends. The goal here is we want
>> Ansible to be able to automatically balance the setup so the front-end
>> servers have been evenly configured to use different backend servers.
>>
>> Is this possible using Ansible ? I was trying to find a similar example
>> using Jinja templates but maybe I was looking at the wrong place ?
>>
>> Any help appreciated.
>>
>> Regards,
>> N.
>>
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/1a1be71f-42d3-4289-958f-d876d43ab449%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/1a1be71f-42d3-4289-958f-d876d43ab449%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 [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/3745ac7e-0b75-4911-9607-ca7aa174b4fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.