我是ansible的新手,我有多个参数传递给YAML,如下所示:
ansible-playbook parse.yaml -e hi,hello
YAML应该一个接一个地分开'hi,hello'而没有分隔符:
你好 喂
我搜索了很多网页,但我找不到任何有用的信息,是否有可能这样做?
答案 0 :(得分:1)
这很简单
ansible-playbook -i hosts playbook.yml -e 'parameter1=hi parameter2=hello'
对于不错的输出,您可以添加" | sed' s / \ n / \ n / g'"
ansible-playbook -i hosts playbook.yml -e 'parameter1=hi parameter2=hello'| sed 's/\\n/\n/g'
cat ./hosts:
localhost
cat playbook.yml:
---
- name: Playbook
hosts: all
become: root
tasks:
- name: output parameter1
debug: msg="{{ parameter1 }}"
- name: output parameter2
debug: msg="{{ parameter2 }}"
- name: output both
debug:
msg: |
{{ parameter1 }}
{{ parameter2 }}