title: replace and lineinfile module does not replace a line
body: <p>I am trying to configure the WSO2 API manager. I have to change some lines in some xml configuration files. </p>
  
  <p>How do I replace in APIM_HOME/repository/conf/api-manager.xml a line </p>
  
  <pre><code>&lt;GatewayEndpoint&gt;http://${carbon.local.ip}:${http.nio.port},https://${carbon.local.ip}:${https.nio.port}&lt;/GatewayEndpoint&gt;
  </code></pre>
  
  <p>with </p>
  
  <pre><code>&lt;GatewayEndpoint&gt;http://ip-111-111-11.abc.xyz.com:1234,https://ip-111-111-11.abc.xyz.com:{https.nio.port}&lt;/GatewayEndpoint&gt;
  </code></pre>
  
  <p>I have tried some regex with lineinfile,replace modules &amp; state=present but it is adding the new line to the end of file. I would rather want to replace the existing line with the new line in same position as that of old line.</p>