I have code that installs a custom seLinux
module. In my fleet of minions there’s Fedora
based systems (with seLinux
installed) and Debian
based ones (without seLinux
). On the latter the module/installing state should not be used and I am thus looking for a way of retrieving a neat answer to the question "is seLinux
installed on this system?" (NOT "is seLinux
enforcing on this system?") to use in a corresponding jinja2
if
clause.
Attempts that have me despairing are:
- there appears to be no state in
salt
querying whether a given binary is on the$PATH
– checking forsestatus
is what I was after here. salt.states.selinux
is not available on systems devoid ofseLinux
, so it’s functionality does not help.- I could not find any
salt
functionality to query for the local availability of something likesalt.states.selinux
(see above) either. - Something like
- unless: - rpm -q libselinux
(from stackoverflow.com/a/31748984/2103880) also does not work, as rpm is Fedora specific…
- Checking for absence of /etc/selinux also is not an option, as the Debian systems actually have that.
Any hint on how to go about this is appreciated.
2
Answers
Following this hint, I ended up doing:
Not what I would call neat and using somewhat convoluted logic, but it appears to do the trick.
If selinux is installed, then a grain is available:
You can also use that grain for minion matching.
In general, you can also check whether a module has been loaded: