Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save riton/21a3fea5f90ffbb2a1f6 to your computer and use it in GitHub Desktop.
Save riton/21a3fea5f90ffbb2a1f6 to your computer and use it in GitHub Desktop.
Ansible / Ephemeral Inventory source
#!/bin/bash
for host in a b c d e
do
echo "host${host}"
done
# ./bin/ansible --version
# ansible 2.1.0 (detached HEAD ephemeral_) last updated 2016/01/26 19:17:58 (GMT +200)
# lib/ansible/modules/core: (detached HEAD 25414bbd1b) last updated 2016/01/26 19:32:32 (GMT +200)
# lib/ansible/modules/extras: (detached HEAD e13942f9c5) last updated 2016/01/26 19:32:39 (GMT +200)
# config file = ~/.ansible.cfg
# configured module search path = Default w/o overrides
$ ./bin/ansible -i <(./cmdb.sh) all --list-hosts
ERROR! the file_name '/dev/fd/63' does not exist, or is not readable
# With the new option
$ ./bin/ansible -i <(./cmdb.sh) all --list-hosts --ephemeral-inventory
hosts (5):
hosta
hostb
hostc
hostd
hoste
# Using inventory from STDIN
$ ./cmdb.sh | ./bin/ansible -i /dev/stdin all --list-hosts --ephemeral-inventory
hosts (5):
hosta
hostb
hostc
hostd
hoste
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment