You save my day Matt, thank you so much .
On Wednesday, May 27, 2015 at 3:04:55 PM UTC-4, Matt Martz wrote:
>
> There might be a different way, but here is one that I can think of:
>
> {% set letters = cycler(*'abcdefghijklmnopqrstuvwxyz'[:]) %}
> slave_hosts={% for host in slaves %}{{ letters.next() }}:{{ host }}{% if
> not loop.last %},{% endif %}{% endfor %}
>
> This creates a 'cycler' with the lowercase letters of the english
> alphabet, and cycles through them on each iteration of the for loop.
>
> On Wed, May 27, 2015 at 1:33 PM, Nicolas G <[email protected]
> <javascript:>> wrote:
>
>> Hi,
>>
>> I need help with the bellow configuration in Jinja, I'm using a for loop
>> to populate the hosts from a group defined in my inventory and that's
>> working good but what my application requires is a letter in front of every
>> host in alphabetical order depending how many host numbers I have :
>>
>>
>> # servers.ini :
>> [server-slaves]
>> server1.example.com
>> server2.example.com
>> server3.example.com
>>
>> # config.conf.j2 :
>> slaves_hosts={% for host in groups['server-slaves'] %}
>> {{ host }}{% if not loop.last %},{% endif %}
>> {% endfor %}
>>
>> # output :
>> slaves_hosts=server1.example.com,server2.example.com,server3.example.com
>>
>> # desired output
>> slaves_hosts=*a*:server1.example.com,*b*:server2.example.com,*c*:
>> server3.example.com
>>
>> This is possible in Chef, any idea if I can do the same in Ansible and
>> how ?
>>
>> Thanks in advance.
>>
>> --
>> 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/25aef324-4ccc-49f1-aac5-d7b96a3db87f%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/25aef324-4ccc-49f1-aac5-d7b96a3db87f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Matt Martz
> @sivel
> sivel.net
>
--
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/d87bcec1-96ea-462a-a751-9a8370bf5d48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.