Allow to configure sysctl values

This patch allows to customize sysctl values on all nodes, by defining
the values in Hiera directly.

Change-Id: Iab8b2f8559d6748f77630d68c48aebed90cf07ec
This commit is contained in:
Emilien Macchi 2015-03-06 20:10:54 -05:00
parent 7040fc0943
commit 4435e1087f
2 changed files with 40 additions and 0 deletions

View File

@ -75,6 +75,19 @@
# },
# }
#
# [*sysctl*]
# (optional) Set of sysctl values to set.
# Defaults {}
# Example:
# {
# 'net.ipv4.ip_forward' => {
# 'value' => '1',
# },
# 'net.ipv6.conf.all.forwarding => {
# 'value' => '1',
# },
# }
#
# [*manage_firewall*]
# (optional) Completely enable or disable firewall settings
# (false means disabled, and true means enabled)
@ -110,6 +123,7 @@ class cloud(
$selinux_booleans = [],
$selinux_modules = [],
$limits = {},
$sysctl = {},
$manage_firewall = false,
$firewall_rules = {},
$purge_firewall_rules = false,
@ -161,6 +175,10 @@ This node is under the control of Puppet ${::puppetversion}.
include ::limits
create_resources('limits::limits', $limits)
# sysctl values
include ::sysctl::base
create_resources('sysctl::value', $sysctl)
# SELinux
if $::osfamily == 'RedHat' {
class {'cloud::selinux' :

View File

@ -64,6 +64,28 @@ describe 'cloud' do
end
context 'with explicit sysctl values' do
before :each do
params.merge!( :sysctl => {
'net.ipv4.ip_forward' => {
'value' => '1',
},
'net.ipv6.conf.all.forwarding' => {
'value' => '1',
}
})
end
it { is_expected.to contain_sysctl('net.ipv4.ip_forward').with(
:val => '1',
) }
it { is_expected.to contain_sysctl('net.ipv6.conf.all.forwarding').with(
:val => '1',
) }
end
it {is_expected.to contain_file('/etc/motd').with(
{:ensure => 'file'}.merge(file_defaults)
)}