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:
vars:
…
server_country_preprod:
hosts:
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] "
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