Skip to content

Commit

Permalink
Merge pull request voxpupuli#198 from oranenj/boolean_types
Browse files Browse the repository at this point in the history
Convert selinux::boolean to puppet types
  • Loading branch information
vinzent authored Feb 23, 2017
2 parents b4ae78c + 693c071 commit 2534853
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions manifests/boolean.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
#
# @example Enable `named_write_master_zones` boolean
# selinux::boolean{ 'named_write_master_zones':
# ensure => "on",
# ensure => 'on',
# }
#
# @example Ensure `named_write_master_zones` boolean is disabled
# selinux::boolean{ 'named_write_master_zones':
# ensure => "off",
# ensure => 'off',
# }
#
# @param ensure Set to on or off
# @param persistent Set to false if you don't want it to survive a reboot.
#
define selinux::boolean (
$ensure = 'on',
$persistent = true,
Variant[Boolean, Enum['on', 'off', 'present', 'absent']] $ensure = 'on',
Boolean $persistent = true,
) {

include ::selinux
Expand All @@ -27,18 +27,15 @@
Anchor['selinux::end']

$ensure_real = $ensure ? {
true => 'true', # lint:ignore:quoted_booleans
false => 'false', # lint:ignore:quoted_booleans
true => 'on',
false => 'off',
default => $ensure,
}

validate_re($ensure_real, ['^on$', '^true$', '^present$', '^off$', '^false$', '^absent$'], 'Valid ensures must be one of on, true, present, off, false, or absent')
validate_bool($persistent)

$value = $ensure_real ? {
/(?i-mx:on|true|present)/ => 'on',
/(?i-mx:off|false|absent)/ => 'off',
default => undef,
/(?i-mx:on|present)/ => 'on',
/(?i-mx:off|absent)/ => 'off',
default => undef,
}

selboolean { $name:
Expand Down

0 comments on commit 2534853

Please sign in to comment.