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
Creating and Running your First Ansible Playbook. Playbooks use the YAML format to define one or more plays. A play is a set of ordered tasks that are arranged in a way to automate a process, such as setting up a web server or deploying an application to production. In a playbook file, plays are defined as a YAML list.
If you want your playbook to prompt the user for certain input, add a 'vars_prompt' section. Prompting the user for variables lets you avoid recording sensitive data like passwords.
You can use conditionals with re-usable tasks files, playbooks, or roles.
Ansible modules are standalone scripts that can be used inside an Ansible playbook. A playbook consists of a play, and a play consists of tasks. These concepts may seem confusing if you're new to Ansible, but as you begin writing and working more with playbooks, they will become familiar.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With