Hi everyone.

When trying to template out a weblogic wl.properties file, I am running 
into a Jinja2 template problem.

Here is a snippet of code I am running into issues with:

################################################################################
# ADDITIONAL MACHINE PROPERTIES
################################################################################
ADDITIONAL_MACHINES={% for server in my_servers %}{{ server }}{% if not 
loop.last %},{% endif %}{% endfor %}

{% for more_servers in my_servers %}
{{ [more_servers] }}LISTEN_ADDRESS={{ ansible_nodename }}
{% endfor %}

BAD OUTPUT:
################################################################################
# ADDITIONAL MACHINE PROPERTIES
################################################################################
ADDITIONAL_MACHINES=myserver02,myserver03,myserver04,myserver05,myserver06,myserver07,myserver08
[u'myserver02']LISTEN_ADDRESS=ansible_host
[u'myserver03']LISTEN_ADDRESS=ansible_host
[u'myserver04']LISTEN_ADDRESS=ansible_host
[u'myserver05']LISTEN_ADDRESS=ansible_host
[u'myserver06']LISTEN_ADDRESS=ansible_host
[u'myserver07']LISTEN_ADDRESS=ansible_host
[u'myserver08']LISTEN_ADDRESS=ansible_host


It appears that the square brackets around the j2 variable more_servers 
cause rendering issues and makes python inject the unicode "u" as well as 
single quotes into the final output. 

EXPECTED OUTPUT:
################################################################################
# ADDITIONAL MACHINE PROPERTIES
################################################################################
ADDITIONAL_MACHINES=myserver02,myserver03,myserver04,myserver05,myserver06,myserver07,myserver08
[myserver02]LISTEN_ADDRESS=ansible_host
[myserver03]LISTEN_ADDRESS=ansible_host
[myserver04]LISTEN_ADDRESS=ansible_host
['myserver05]LISTEN_ADDRESS=ansible_host
[myserver06]LISTEN_ADDRESS=ansible_host
[myserver07]LISTEN_ADDRESS=ansible_host
[myserver08]LISTEN_ADDRESS=ansible_host


I have tried many different filters to get this to work, but just cannot 
get it. Filters include: to_json, to_nice_json, to_yaml, to_nice_yaml,join, 
replace.

Any help would be greatly appreciated! 

 - Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/c0eb5d63-a2a4-4276-90f6-93db66c74cdd%40googlegroups.com.

Reply via email to