Skip to content

Commit

Permalink
This is fix for salt-formulas#182 part 2. Add backward compatibility.
Browse files Browse the repository at this point in the history
- We will check now if pillar system.selinux is a map for new format
- If system.selinux is not a map use old format
- policycoreutils and policycoreutils-python are not nessasary for basic selinux configuration
  we need this packages later to add selinux rules.
- Added new format to test pillars
  • Loading branch information
Nick Metz authored and Nick Metz committed Nov 22, 2018
1 parent 9d259d4 commit a8dee64
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion linux/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
},
},
'RedHat': {
'pkgs': ['policycoreutils', 'policycoreutils-python', 'telnet', 'wget'],
'pkgs': ['telnet', 'wget'],
'utc': true,
'user': {},
'group': {},
Expand Down
14 changes: 12 additions & 2 deletions linux/system/selinux.sls
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{%- from "linux/map.jinja" import system with context %}
{%- if system.selinux is defined %}
{%- if grains.os_family == 'RedHat' %}
{% if system.selinux is mapping %}
{% if system.selinux.pkgs %}
linux_system_selinux_pkgs:
pkg.installed:
- pkgs: {{ system.selinux.pkgs }}
{%- endif %}
{%- if grains.os_family == 'RedHat' %}
{%- if system.selinux.mode %}
{{ system.selinux.mode }}:
selinux.mode:
- require:
- pkg: linux_system_selinux_pkgs
{%- endif %}
{%- else %}
{{ system.selinux }}:
selinux.mode
{%- endif %}
{%- endif %}
{%- endif %}
3 changes: 2 additions & 1 deletion tests/pillar/system.sls
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ linux:
domain: ci.local
environment: prd
purge_repos: true
selinux: permissive
selinux:
mode: permissive
directory:
/tmp/test:
makedirs: true
Expand Down

0 comments on commit a8dee64

Please sign in to comment.