"groups is not inside {{ ... }}, so it isn't evaluated at all. Also you
cannot
nest the curly braces."
Oh ok, I understand
I try this {{ groups[ var1 + '_' var2 + '_prod' ][0] }}",
and it's work perfectly, realy thank you for your help to an ansible newbie
dev :-)
Best regards
Le mardi 27 octobre 2020 à 15:04:53 UTC+1, [email protected] a écrit :
> On 10/27/20 3:55 PM, desmond humes wrote:
> > Hi everybody,
> > I hope this the good place to post my problem.
> >
> > I have declared this inventory in yml
> > all:
> > children:
> > server_country_prod:
> > hosts:
> > server1.com <http://server1.com/>:
> > vars:
> > ...
> >
> > server_country_preprod:
> > hosts:
> > server2.com <http://server2.com/>:
> > vars:
> > ....
> > vars:
> > ansible_ssh_user: user
> > ansible_user: user
> > ansible_connection: ssh
> > ssh_args: -o ForwardAgent=yes
> >
> > If I write that
> > - hosts: "{{ groups['server_country_prod'][0] }}"
> > #gather_facts: no
> > become: yes
> > I can lauch my playbook easily
> >
> > But if I want lauching my playbook with extra var
> > ansible-playbook -i inventory.yml -e var1=server -e var2=country
> tasks/main.yml
> >
> > I can't lauch my playbook what I have writing
> > - hosts: " groups['{{var1}}_{{var2}}_prod'][0] "
>
> groups is not inside {{ ... }}, so it isn't evaluated at all. Also you
> cannot
> nest the curly braces.
>
> Try "{{ groups[ var1 + '_' var2 + '_prod' ][0] }}" (untested).
>
> Regards
> Racke
>
> >
> > I have the following error:
> > PLAY [groups['server_country_prod'][0]]
> >
> ****************************************************************************************************************************************************************************
> > skipping: no hosts matched
> >
> > Somebody can help me to understand why?
> > Thanks for your read and your help.
> > Best regards
> >
> > --
> > 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] <mailto:
> [email protected]>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/84fb4a9d-53e3-4a7d-87ee-8cc1f082b1b7n%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/84fb4a9d-53e3-4a7d-87ee-8cc1f082b1b7n%40googlegroups.com?utm_medium=email&utm_source=footer
> >.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/bf66c276-84eb-4f7f-910e-c5d55ba0739dn%40googlegroups.com.