singuliere
singuliere

Reputation: 857

can ansible-playbook read from stdin instead of a file?

Is it possible for ansible-playbook to read a playbook from the standard input? I thought maybe dash (-) would be a way to specify stdin, like it does in the cat command and I tried:

$ ansible-playbook -

But it fails with:

ERROR! the playbook: - could not be found

Upvotes: 12

Views: 4071

Answers (1)

mdaniel
mdaniel

Reputation: 33223

The thing you are looking for is /dev/stdin, which acts like a file but, as its name implies, is the stdin of the current process.

$ 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

Upvotes: 19

Related Questions