ansible-playbook可以从stdin读取而不是从文件读取吗?

sin*_*ere 4 ansible

是否可以ansible-playbook从标准输入中读取剧本?我以为连字符(-)可能是一种指定方式stdin,就像cat命令中那样,我尝试过:

$ ansible-playbook -
Run Code Online (Sandbox Code Playgroud)

但是它失败了:

ERROR! the playbook: - could not be found
Run Code Online (Sandbox Code Playgroud)

mda*_*iel 6

您正在寻找的是/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
Run Code Online (Sandbox Code Playgroud)