I have a template of a system.d service script that I get filled using Ansible playbook.
The template includes experssion
[Service]
Environment="JAVA_OPTS=-Djava.net.preferIPv4Stack=true -Denvironmentname={{environment_name | default('NOT_SET') }}"
where environment_name above is a variable present in Ansible while running the playbook. Playbook has this instruction:
- name: Copy systemd service script
template: src=systemd.service dest="{{systemd_dir}}/{{systemd_service_name}}.service"
I want to add memory-related parameters to the JAVA_OPTS such as:
if environment_name=DEV, then add to JAVA_OPTS '-Xmx=2000Mb -Xms=1000Mb', if environment_name=PROD, then add '-Xmx=20000Mb -Xms=10000Mb'*, etc (I have several environments).
How I can encode such substitutions in template or in calling script?