I wanted to supply a playbook to ansible-playbook 2.4.2.0 from stdin on RHEL 7.5, I found this post which seemed very promising but it's not working for me:
$ cat ~/simple-ansible-playbook.yaml | ansible-playbook -i ~/inventory.yaml /dev/stdin
ERROR! Unable to retrieve file contents
Could not find or access '/dev/stdin'
$
I tracked down the message to /usr/lib/python2.7/site-packages/ansible/parsing/dataloader.py
:
if not self.path_exists(b_file_name) or not self.is_file(b_file_name):
raise AnsibleFileNotFound("Unable to retrieve file contents", file_name=file_name)
os.path.isfile()
returns False
for /dev/stdin
which is a symlink to a character special file:
$ ls -l /dev/stdin
lrwxrwxrwx. 1 root root 15 Nov 11 13:11 /dev/stdin -> /proc/self/fd/0
$ ls -Ll /dev/stdin
crw--w----. 1 stack tty 136, 3 Feb 15 07:45 /dev/stdin
Does anyone have any ideas how to get this to work? I don't understand why it seemed to work for the cited post but it's not working for me.
Update
I think I understand this better. The original post used a here document which the shell apparently returns into a regular file. In my method, the data is in a pipe. I didn't realize the shell behaved differently in this respect: I figured the here document would result in a pipe too. So at least I learned something new about the difference but apparently I can't do what I want unless ansible-playbook
changes.