Thanks, Igor, I’ll give that a try. I thought it might have something to do 
with how the task was set up, but since there was no example given for 
that, I was just guessing, grasping at straws.

On Thursday, July 30, 2015 at 11:35:04 PM UTC-4, Igor Cicimov wrote:
>
> You forgot to include condition in the tasks, like for example: 
>
> - name: Template to 1st server.xml
>   template: src=server.xml.j2 dest=/var/opt/tomcat_1/conf/server.xml 
> owner=tomcat7 group=nogroup mode=0600
>   when: port == "5000"
>  
> - name: Template to 2nd server.xml
>   template: src=server.xml.j2 dest=/var/opt/tomcat_2/conf/server.xml 
> owner=tomcat7 group=nogroup mode=0600
>   when: port == "5001"
>
> otherwise each will get executed on each run, of course.
>
> On Thursday, July 30, 2015 at 4:23:41 AM UTC+10, Roger Sherman wrote:
>>
>> I have a group of hosts that have two tomcat instances on them, and I 
>> need the server.xml to have different values in each instance. Initially, I 
>> tried to write a jinja2 loop into a template, which I bailed on when 
>> someone in the IRC channel pointed out parameterizing the role (from 
>> http://docs.ansible.com/ansible/playbooks_roles.html - there's not a 
>> direct anchor, so I'll quote):
>>
>> Also, should you wish to parameterize roles, by adding variables, you can 
>>> do so, like this:
>>
>> - hosts: webservers
>> roles:
>> - common
>> - { role: foo_app_instance, dir: '/opt/a', port: 5000 } 
>> - { role: foo_app_instance, dir: '/opt/b', port: 5001 } 
>>
>>  But when I try the above, both server.xml's end up with the same value. 
>> It looks like each subsequent pass through the role puts it's value in both 
>> directories, so after the second time it runs, both server.xml's have the 
>> second value. I pastebinned my playbook, role, and the line from the 
>> template: http://pastebin.com/eDMQkY3H
>>
>> If anybody could help me with this, or tell me what I'm doing wrong, I'd 
>> greatly appreciate it.
>>
>

-- 
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/caaedf5e-8411-407b-8316-0740c7d4058a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to