Python - ValueError: I/O operation on closed file

231 views
Skip to first unread message

Slim Slam

unread,
Feb 29, 2016, 6:51:08 PM2/29/16
to Ansible Project
Ansible 2.0.1 

When I ssh into a Linux server and run:

$ ansible-playbook -vvvvvv build.yml

it runs fine. 

But if I ssh into the Linux server and run:

$ nohup ansible-playbook -vvvvvv build.yml

or

$ ansible-playbook -vvvvvv build.yml > output &

or

$ nohup ansible-playbook -vvvvvv build.yml > nohup.out

or

$ nohup ansible-playbook -vvvvvv build.yml > nohup.out 2>&1 &


it always fails on this task:

- name: wait for something to happen
  pause
: seconds=15

Like this:

TASK [wait for something to happen] **************************************************
task path
: /build.yml:94
Pausing for 15 seconds
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/
usr/local/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 120, in run
    res = self._execute()
  File "
/usr/local/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 418, in _execute
    result = self._handler.run(task_vars=variables)
  File "
/usr/local/lib/python2.7/site-packages/ansible/plugins/action/pause.py", line 123, in run
    fd = self._connection._new_stdin.fileno()
ValueError: I/O operation on closed file
fatal: [localhost]: FAILED! => {"
failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}

I'm pretty sure it has something to do with STDOUT not being available but I'm not sure of the workaround. Anyone
have a suggestion?

===

Slim Slam

unread,
Mar 1, 2016, 9:09:37 AM3/1/16
to Ansible Project
I guess I don't even understand why the Ansible "pause" module would care about stdout.

J

Slim Slam

unread,
Mar 1, 2016, 6:02:05 PM3/1/16
to Ansible Project
Looking at the code for the pause module:

if seconds is not None:
   
# setup the alarm handler
   signal
.signal(signal.SIGALRM, timeout_handler)
   signal
.alarm(seconds)
   
# show the prompt
   display
.display("Pausing for %d seconds" % seconds)
   display
.display("(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)\r"),
else:
  display
.display(prompt)

Even if you only want pause to wait some amount of time, the module still expects STDIN to be available after prompting for ctrl+C.

So, this worked:

$ nohup ansible-playbook -vvvvvv build.yml 0</dev/null

It keeps STDIN open but provides no input. 

Slim Slam

unread,
Mar 2, 2016, 3:22:57 PM3/2/16
to Ansible Project
Looks like this issue was fixed today:    https://github.com/ansible/ansible/pull/14755
Reply all
Reply to author
Forward
0 new messages