-
Notifications
You must be signed in to change notification settings - Fork 23.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "invalid selinux context" with template module and NFS #56243
Comments
Files identified in the description: If these files are inaccurate, please update the |
Just upgraded to Red Hat 8.1 and using ansible 2.9.1 with python 3.6.8 and having the same issue writing (copy module) to NFS file system with SELinux. Anyone have a solution? |
I seem to also be having this issue with Ansible 2.9.2 and Python 3.6.8 running on CentOS 8. In my case I am seeing the same error message when attempting to template a file on a vagrant mount, ie a I've had a bit of a look into this, my suspicion is that the is_special_selinux_path method is always returning a When attempting to template a new file, the value of
It seems that when templating a new file, this variable appears to be in bytes (for my particular case this was However, the values of So the conditional that determines whether the mounts match ( Once I hacked this method to coerce
then this appears to fix the Interestingly enough, |
One workaround for this issue seems to be to ensure that the destination file already exists before using the 'template' module, eg:
This seems to work for me with both I suspect one other workaround to investigate could be to try running ansible using python 2 if your operating system still has that available. |
@tmiller02 Thanks for the workaround. This also helped me to work around the issue. Can you possibly create a pull request with the changes mentioned above in the code? |
I do have the same issue with awx under centos 7 |
@tmiller02 in CentOS 7, for me this problem happens only with python 3. It works normally with python 2. I cannot believe that this bug has not gotten higher attention. For almost 1 year the template module needs a workaround to create the file first? |
I do not think this SELinux problem is restricted to NFS. Any file that I am creating with the template module does not get labeled according to SELinux file contexts -- they always get the same context from the temporary file location: |
Files identified in the description: If these files are incorrect, please update the |
For the record I just had this problem with Ansible 2.9.12 and Python 3.6.8 on CentOS 8.2.2004 - trying to create a README file with some content using the copy module after disabling SELinux with selinux module fails with error " |
Move fast, break things...... |
What is the ETA on this fix? |
does this patch fix the issue?
|
Yes it does. Thank you! |
SUMMARY
ISSUE TYPE
COMPONENT NAME
template module
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Target host running Fedora 30 with SELinux permissive using Python 3 as interpreter
STEPS TO REPRODUCE
Vagrant box used to reproduce this issue is available here: https://github.com/netoarmando/test-ansible-selinux
EXPECTED RESULTS
template
module must succeed when writing files in NFS shares.ACTUAL RESULTS
Possibly related to issues #29685 and #29728.
The text was updated successfully, but these errors were encountered: