replace和lineinfile模块不替换行

时间:2016-09-10 14:35:36

标签: ansible ansible-playbook ansible-2.x

我正在尝试配置WSO2 API管理器。我必须在一些xml配置文件中更改一些行。

如何在APIM_HOME / repository / conf / api-manager.xml中替换一行

<GatewayEndpoint>http://${carbon.local.ip}:${http.nio.port},https://${carbon.local.ip}:${https.nio.port}</GatewayEndpoint>

<GatewayEndpoint>http://ip-111-111-11.abc.xyz.com:1234,https://ip-111-111-11.abc.xyz.com:{https.nio.port}</GatewayEndpoint>

我用lineinfile尝试了一些正则表达式,替换模块和放大器state = present但它将新行添加到文件末尾。我宁愿用新线替换现有的线,与旧线的位置相同。

1 个答案:

答案 0 :(得分:1)

试试这个 -

$ ->
  $(document).on 'change', '#selectJdField', (evt) ->
      updateLists()
  $(document).on 'click', "#btnFind", (evt) ->
     updateLists()
  updateLists = () ->
   $.ajax  '/updateJobs',
    type: 'GET'
    dataType: 'script'
    data:   {
     selectJdField2 :   $('#selectJdField').val()   
    }

这对我有用,取而代之的是

- name: "Test lineinfile"
  lineinfile:
    dest: "/etc/ansible/lineinfile.xml"
    state: "present"
    line: "<GatewayEndpoint>http://ip-111-111-11.abc.xyz.com:1234,https://ip-111-111-11.abc.xyz.com:{https.nio.port}</GatewayEndpoint>"
    regexp: "<GatewayEndpoint>"

<GatewayEndpoint>http://${carbon.local.ip}:${http.nio.port},https://${carbon.local.ip}:${https.nio.port}</GatewayEndpoint>
相关问题