我试图在Ansible(ansible-2.1.1.0-1.fc24.noarch)剧本中的一个变量中"清理"空格,我虽然我先拆分()然后再加入('').由于某种原因,这种方法给我以下错误: - /
---
- hosts: all
remote_user: root
vars:
mytext: |
hello
there how are
you?
tasks:
- debug:
msg: "{{ mytext }}"
- debug:
msg: "{{ mytext.split() }}"
- debug:
msg: "{{ mytext.split().join(' ') }}"
...
Run Code Online (Sandbox Code Playgroud)
给我:
TASK [debug] *******************************************************************
ok: [192.168.122.193] => {
"msg": "hello\nthere how are\nyou?\n"
}
TASK [debug] *******************************************************************
ok: [192.168.122.193] => {
"msg": [
"hello",
"there",
"how",
"are",
"you?"
]
}
TASK [debug] *******************************************************************
fatal: [192.168.122.193]: FAILED! => {"failed": true, …Run Code Online (Sandbox Code Playgroud)