Ansible匹配并使用正则expression式更改bash提示符

我想从中更改bash命令提示string

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 

 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 

具体来说,它将颜色从绿色变为红色,更改为32到31。

我想更改文件,而不是部署/复制在一个完整的文件。

我想通过文件search,并更改线,如果它匹配的任何情况。

我试着逃避所有的特殊字符,但YAML正则expression式抱怨\和各种字符。

为什么不把PS1设置为所需的值?

 - lineinfile: create: yes mode: 0600 dest: /root/.bash_aliases owner: root regexp: '^PS1=' line: 'PS1="${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "' state: present 

我使用单引号作为外部的引号,因为它不需要转义字符。