including host_vars in with_items using roles

Hi all,

I’m trying to use one role for two different hosts, each one using different playbooks.
The behaviour I’m expecting is if I have n-deploy-web hosts they should get trackX.war copied in /var/lib/tomcat6/webapps, but if it’s n-deploy-dcs hosts they should get mdrcX.war,mdlsX.war,ctracfreeX.war

At first, running the playbook I get sintax error due to the braces… but removing them I get /path/to/deploy_files.war doesn’t exists.

If there’s a way to get this running… link to the docs, examples or whatever that could help me… I will appreciate it.

$cat hosts
[deploy-web]
192.168.5.215

[deploy-web:vars]
service=livetrack
service_num=1
deploy_files=track

[deploy-dcs]
192.168.5.215

[deploy-dcs:vars]
service=livetrack
service_num=1
deploy_files=[mdrc,mdls,ctracfree]

$cat deploy.yml

Sure, this is a simple YAML gotcha.

If you have something that is like

foo: {{ bar }}

You have to quote it so YAML doesn’t think you mean a dictionary:

foo: “{{ bar }}”

Also don’t do $item, better to standardize on {{ item }} there too

As I say in my native language… “Gracias”.

It worked for the deploy-web.yml playbook, but now I’m facing another issue, is this syntax correct?

deploy_files=[mdrc,mdls,ctracfree]

The deploy-dcs.yml playbook fails saying path/to/file don’t exist.

You cannot define structured variables in your INI files (at least, not in 1.3)

Look into “group_vars/groupname” files and “host_vars/hostname” directories alongside your inventory file, and this is a great place to define structured data.