Below is how i call my ansible-playbook and pass application names as 
parameters APP1 & APP2

ansible-playbook -i /web/aes/admin/playbooks/updated.hosts 
/web/aes/admin/playbooks/split.yml -e ENV=qa -e NODE=cluster -e 
instance_name=APP1,APP2

Playbook:

---
- hosts: "{{ [ENV] | product(instance_name.split(',')) | product([NODE]) | 
product(['wladmin_mmsplit'])|map('flatten')|map('join', '_') }}"
  user: wladmin
  gather_facts: no

I get the desired Output as below:

PLAY [['qa_APP1_cluster_wladmin_mmsplit', 
'qa_APP2_cluster_wladmin_mmsplit']]

The problem occurs when i pass the application names as 
APP1-brazil & APP2-Chile

and wish the same output as before.

ansible-playbook -i /web/aes/admin/playbooks/updated.hosts 
/web/aes/admin/playbooks/split.yml -e ENV=qa -e NODE=cluster -e 
instance_name=APP1-brazil,APP2-Chile

I tried the below but i get error:

- hosts: "{{ [ENV] | product(instance_name.split(',') | split('-')[0]) | 
product([NODE]) | product(['wladmin_mmsplit'])|map('flatten')|map('join', 
'_') }}"

Error in output:

ERROR! template error while templating string: expected token ',', got '['. 
String: {{ [ENV] | product(instance_name.split(',') | split('-')[0]) | 
product([NODE]) | product(['wladmin_mmsplit'])|map('flatten')|map('join', 
'_') }}

Can you please suggest how can i address this requirement? 
 

-- 
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/da1f5460-e7c8-4e84-814a-ed3b2e3a9828n%40googlegroups.com.

Reply via email to