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

问题描述 投票:2回答:1

ansible-playbook可以从标准输入读取剧本吗?我想也许破折号( - )将是一种指定stdin的方式,就像在cat命令中一样,我试过:

$ ansible-playbook -

但它失败了:

ERROR! the playbook: - could not be found
ansible
1个回答
4
投票

你正在寻找的是/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
© www.soinside.com 2019 - 2024. All rights reserved.