Reputation: 11
I am doing a script to automate file editing on server when deploying an agent of some service, the file is config.xml and I am editing fields using replace, so for eg.:
- name: Update config.xml - PROXY HOST
replace:
path: "{{agent_path}}{{ cfg_agent }}/agent/config.xml"
regexp: "YOUR_PROXY_HOST"
replace: "{{cfg_proxyhost}}"
Config.xml looks like:
<!--
<parameter name="mid.proxy.use_proxy" value="true"/>
<parameter name="mid.proxy.host" value="YOUR_PROXY_HOST"/>
<parameter name="mid.proxy.port" value="YOUR_PROXY_PORT"/>
-->
So when I run this particular task it will replace YOUR_PROXY_HOST for a value under {{cfg_proxyhost}}, let's say like that:
<!--
<parameter name="mid.proxy.use_proxy" value="true"/>
<parameter name="mid.proxy.host" value="http://proxy.foo"/>
<parameter name="mid.proxy.port" value="YOUR_PROXY_PORT"/>
-->
But then I need to remove those <!--
above and -->
below to make it working.
There is a lot of other parameters in the file commented in the same way.
I need to remove these particular ones.
How can it be done using ansible?
Upvotes: 0
Views: 330
Reputation: 11
Actually I have resolved it by using Jinja2 template, replacing the files with a pre-defined variables within a template, but if any of You could answer how to just remove that comment, that will be nice :)
Upvotes: 1