Why am I Getting an Unexpected Exception Error in Ansible Command?

Solution In Progress - Updated -

Environment

  • Red Hat Enterprise Linux 7 (RHEL)
  • Ansible Engine

Issue

When running an Ansible command line or playbook, it fails with:

  ERROR! Unexpected Exception, this is probably a bug: [Errno 13] Permission denied

or

  ERROR! Unexpected Exception, this is probably a bug: [Errno 2] No such file or directory

Resolution

If /dev/shm permission is not 1777, set proper permission to /dev/shm.

# chmod 1777 /dev/shm

Root Cause

The /dev/shm permission was changed from 1777.

# ls -ld /dev/shm
drwxr-xr-t. 2 root root 40 Aug 21 00:24 /dev/shm

This is a known issue: https://github.com/ansible/ansible/issues/25193

Diagnostic Steps

When not a root user, you can find standard output like this;

$ ansible -i someinventory all -m ping -vvv
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/foobar/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, May 31 2018, 09:41:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /etc/ansible/ansible.cfg as config file
Parsed /home/foobar/someinventory inventory source with ini plugin
ERROR! Unexpected Exception, this is probably a bug: [Errno 13] Permission denied
the full traceback was:

Traceback (most recent call last):
  File "/bin/ansible", line 106, in <module>
    exit_code = cli.run()
    ...
  File "/usr/lib64/python2.7/multiprocessing/synchronize.py", line 147, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1)
  File "/usr/lib64/python2.7/multiprocessing/synchronize.py", line 75, in __init__
    sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
OSError: [Errno 13] Permission denied

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments