ansible-playbook
可以从标准输入读取剧本吗?我想也许破折号( - )将是一种指定stdin
的方式,就像在cat
命令中一样,我试过:
$ ansible-playbook -
但它失败了:
ERROR! the playbook: - could not be found
你正在寻找的是/dev/stdin
,它就像一个文件,但顾名思义,它是当前进程的标准。
$ ansible-playbook -i localhost, -c local /dev/stdin <<'FOO'
- hosts: all
tasks:
- debug: msg="hello from stdin"
FOO
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] =>
msg: hello from stdin