In Ansible, how do I add a line to the end of a file?

后端 未结 2 1349
别那么骄傲
别那么骄傲 2020-12-14 05:44

I would expect this to be pretty simple. I\'m using the lineinfile module like so:

- name: Update bashrc for PythonBrew for foo user
  lineinfil         


        
2条回答
  •  醉话见心
    2020-12-14 06:33

    Apparently ansible has matured and now (version >2.4.0) according to the documentation, The defaults when only the line is specified will append a given line to the destination file:

        - name: Update bashrc for PythonBrew for foo user
          lineinfile:
            dest: /home/foo/.bashrc
            line: "[[ -s ${pythonbrew.bashrc_path} ]] && source {pythonbrew.bashrc_path}"
            owner: foo
    

提交回复
热议问题