I am using this Ansible task to deploy an rpm package to an RHEL8 server:
- name: Add the shibboleth Repository configuration
yum_repository:
name: security_shibboleth
description: Shibboleth (CentOS_7)
setype: rpm-md
mirrorlist: https://shibboleth.net/cgi-bin/mirrorlist.cgi/CentOS_7
gpgkey:
- https://shibboleth.net/downloads/service-provider/RPMS/repomd.xml.key
- https://shibboleth.net/downloads/service-provider/RPMS/cantor.repomd.xml.key
gpgcheck: true
enabled: true
tags:
- shibboleth
However, the task fails with this SELinux error:
fatal: [proxy_server_46]: FAILED! => {"changed": false, "cur_context": ["unconfined_u", "object_r", "system_conf_t", "s0"], "gid": 0, "group": "root", "input_was": [null, null, "rpm-md", null], "mode": "0644", "msg": "invalid selinux context: [Errno 22] Invalid argument", "new_context": ["unconfined_u", "object_r", "rpm-md", "s0"], "owner": "root", "path": "/etc/yum.repos.d/security_shibboleth.repo", "secontext": "unconfined_u:object_r:system_conf_t:s0", "size": 312, "state": "file", "uid": 0}
Any ideas what's going wrong here? Googling for this error type unfortunately did not deliver any helpful results.
The
yum_repositorymodule (to) Add or remove YUM repositories is more or less to create a YUM repository file (.repo) under location/etc/yum.repos.d/only. This in mind, a minimal example playbookwill generate the "text" file in INI style.
Looking at the module Parameter documentation one may notice that there is no parameter for
type.It is also not necessary to set such on plain Red Hat / Fedora / Cent OS distributions. For some background information see Red Hat Bugzilla - Bug 1373317 - RFE: Add "type=rpm-md" and "repo_gpgcheck=0" to Fedora repo files.
Whereby a
typewould be necessary to describe the repository for the underlaying package manager in more detail and which is not necessary in the given case, the parametersetypefor settingto
rpm-mdof course and obviously will not exist. Therefore the error messageTo Summarize
repo.
type != setype.How to resolve?
from most to less recommended ...
setype: rpm-mdtemplatemodule (to) Template a file out to a target host withdest: /etc/yum.repos.d/security_shibboleth.repofrom a respecting Jinj2 Templatecommunity.general.ini_fileinstead."ini_filemodule (to create) settings in INI files from the beginniglineinfilemodule (to) Manage lines in text files to add the linetype: rpm-mdafterwardsansible/modules/yum_repository.py... interesting is that according the actual module source code
yum_repository.pythere seems to be no parametersselevel,serole,setypeandseuser(anymore). It wasn't possible to find when and where they were introduced or removed. They were there at least at Ansible Issue #23913 and in Ansible version 2.2, but not anymore in Ansible version 2.8. The parameters are also reported in myansible [core 2.11.12]viaansible-doc yum_repositoryeven if the source code says they are not there ... :-/