Ansible: Insert line if not exists

后端 未结 10 1298
庸人自扰
庸人自扰 2020-12-25 11:27

I\'m trying insert a line in a property file using ansible. I want to add some property if it does not exist, but not replace it if such property already exists in the file.

10条回答
  •  离开以前
    2020-12-25 11:57

    - name: add couchbase.host to properties, works like add or replace
      lineinfile: 
        state: present
        dest: /database.properties 
        regexp: '^couchbase.host'
        line: 'couchbase.host=127.0.0.1'
    

提交回复
热议问题