Ansible Playbook 不断将 ^M 添加到我的文件中 [英] Ansible Playbook keeps adding ^M to my files

查看:33
本文介绍了Ansible Playbook 不断将 ^M 添加到我的文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的 ansible playbook,我在其中识别文件中的一个字符串并将其替换为另一个

I have the below ansible playbook where i am identifying a string in a file and replacing it with another

---
- name: Ansible Playbook
  hosts: webserver1
  remote_user: user45

  tasks:
  - name: Replacing content with other
    lineinfile:
     path: /home/user45/run.sh
     regexp: '^(.*)DEBUG=(.*)$'
     line: 'DEBUG=ON'

上述工作,但它添加 ^M 到该文件中的每个其他行和每个空行的末尾

the above works, but it adds ^M to the end of every other line in that file and every blank line

从我在网上阅读的内容来看,这通常发生在您从 Windows 复制并粘贴到 Linux 时,但我是手动输入的,所以我有点困惑

From what I have read online this normally occurs when you copy and paste from Windows to Linux but i typed this out manually so i am kind of stumped

Playbook 在 Linux Redhat 7 上运行

Playbook is running on Linux Redhat 7

推荐答案

无论出于何种原因,lineinfile 都添加了 ^M .. 如果我将其更改为使用替换模块,它不会添加 ^M 位

For whatever reason lineinfile was adding the ^M .. If I change it to use replace module it does not add the ^M bits

---
- name: Ansible Playbook
  hosts: webserver1
  remote_user: user45

  tasks:
  - name: Replacing content with other
    replace:
     dest: /home/user45/run.sh
     regexp: 'DEBUG=.*'
     line: 'DEBUG=ON'

这篇关于Ansible Playbook 不断将 ^M 添加到我的文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆