The Ansible task "Distribute public key" fails with the message "invalid selinux context: [Errno 95] Operation not supported"


When you execute Ansible playbooks, such as site.yml or multi-tenancy.yml, on SAS® Viya®, the following error message might occur during the “Distribute public key” task:

"msg": "invalid selinux context: [Errno 95] Operation not supported",


The error appears when all of the following characteristics are true:


GitHub provides information about the cause and a fix.

To work around the problem, you can set SELinux to permissive mode or disabled, and then re-execute the Ansible playbook.

Otherwise, another option is to manually make the changes recommended on GitHub, as outlined here:

1. Locate and make a backup copy of the basic.py file, located in /usr/local/lib/python3.6/site-packages/ansible/moduleutils/.

Note: Since the Python version could be a 3.x version instead of 3.6, the exact path here might vary.
 
2. Edit the basic.py file, and search for the is_special_selinux_path function. That function begins with a line that looks like this:

def isspecialselinuxpath(self, path):

3. Approximately 15 lines into the is_special_selinux_path function, you should find a line that looks like this:

if path_mount_point == mount_point:

4. Change that line to the line below, making sure to keep the same indention as the original line:

if to_bytes(path_mount_point) == to_bytes(mount_point):
 

5. Save the basic.py file, and then re-execute the Ansible playbook.