Revert "Sync sysctl module to v0.0.4 from upstream"
Partial-bug: #1337415
This reverts commit 6587dca0e9
.
Change-Id: I86d233e77ac8107f034a494a725fe6947fb94427
This commit is contained in:
parent
6587dca0e9
commit
945ae2b897
|
@ -1 +1,5 @@
|
|||
*.swp
|
||||
pkg/
|
||||
.DS_Store
|
||||
metadata.json
|
||||
coverage/
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>sysctl</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
|
||||
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,16 +0,0 @@
|
|||
rvm:
|
||||
- 1.8.7
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
- 2.1.0
|
||||
script: 'bundle exec rake spec'
|
||||
env:
|
||||
- PUPPET_VERSION=2.7.25
|
||||
- PUPPET_VERSION=3.6.1
|
||||
matrix:
|
||||
exclude:
|
||||
# No support for Ruby 2.0 before Puppet 3.2
|
||||
- rvm: 2.0.0
|
||||
env: PUPPET_VERSION=2.7.25
|
||||
- rvm: 2.1.0
|
||||
env: PUPPET_VERSION=2.7.25
|
|
@ -1,14 +0,0 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
### Environment variable version overrrides
|
||||
### Gem requirements
|
||||
gem 'rake'
|
||||
gem 'rspec'
|
||||
gem 'facter'
|
||||
gem 'puppet', '>= 3.0.0'
|
||||
gem 'rspec-puppet'
|
||||
#gem 'simplecov'
|
||||
gem 'puppet-lint'
|
||||
gem 'puppetlabs_spec_helper'
|
||||
gem 'git', '>= 1.2.6'
|
||||
gem "ci_reporter"
|
|
@ -1,5 +1,5 @@
|
|||
name 'duritong-sysctl'
|
||||
version '0.0.4'
|
||||
version '0.0.1'
|
||||
description "This modules allows you to configure sysctl."
|
||||
license 'GPLv2'
|
||||
project_page 'https://github.com/duritong/puppet-sysctl'
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
= Requirements
|
||||
|
||||
= Overview
|
||||
|
||||
This modules allows to configure sysctl.
|
||||
|
||||
= Usage
|
||||
|
||||
node "mynode" inherits ... {
|
||||
sysctl::value { "vm.nr_hugepages": value => "1583"}
|
||||
}
|
||||
|
||||
When setting a key that contains multiple values, use a tab to separate the
|
||||
values:
|
||||
|
||||
node "mynode" inherits ... {
|
||||
sysctl::value { 'net.ipv4.tcp_rmem':
|
||||
value => "4096\t131072\t131072",
|
||||
}
|
||||
}
|
||||
|
||||
It is preferred that you set your exec path globally. This is usually done
|
||||
in site.pp and would look something like this (adjust for your environment):
|
||||
|
||||
# Set a site-wide global path so we don't have to explicitly specify a path
|
||||
# for each exec.
|
||||
Exec { path => '/usr/bin:/usr/sbin/:/bin:/sbin' }
|
||||
|
||||
= License
|
||||
|
||||
Copyright (C) 2011 Immerda Project Group
|
||||
Author mh <mh@immerda.ch>
|
||||
Modified by Nicolas Zin <nicolas.zin@savoirfairelinux.com>
|
||||
Licence: GPL v2
|
|
@ -1,58 +0,0 @@
|
|||
Requirements
|
||||
============
|
||||
|
||||
[![Build Status](https://travis-ci.org/duritong/puppet-sysctl.png?branch=master)](https://travis-ci.org/duritong/puppet-sysctl)
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
This modules allows to configure sysctl.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
node "mynode" inherits ... {
|
||||
sysctl::value { "vm.nr_hugepages": value => "1583"}
|
||||
}
|
||||
|
||||
When setting a key that contains multiple values, use a tab to separate the
|
||||
values:
|
||||
|
||||
node "mynode" inherits ... {
|
||||
sysctl::value { 'net.ipv4.tcp_rmem':
|
||||
value => "4096\t131072\t131072",
|
||||
}
|
||||
}
|
||||
|
||||
To avoid duplication the sysctl::value calls multiple settings can be
|
||||
managed like this:
|
||||
|
||||
$my_sysctl_settings = {
|
||||
"net.ipv4.ip_forward" => { value => 1 },
|
||||
"net.ipv6.conf.all.forwarding" => { value => 1 },
|
||||
}
|
||||
|
||||
# Specify defaults for all the sysctl::value to be created (
|
||||
$my_sysctl_defaults = {
|
||||
require => Package['aa']
|
||||
}
|
||||
|
||||
create_resources(sysctl::value,$my_sysctl_settings,$my_sysctl_defaults)
|
||||
|
||||
The sysctl binary needs to be found in your Path.
|
||||
It is preferred that you set your exec path globally. This is usually done
|
||||
in site.pp and would look something like this (adjust for your environment):
|
||||
|
||||
# Set a site-wide global path so we don't have to explicitly specify a path
|
||||
# for each exec.
|
||||
Exec { path => '/usr/bin:/usr/sbin:/bin:/sbin' }
|
||||
|
||||
Or you can also set that path within hiera for `sysctl::params::exec_path`.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (C) 2011 Immerda Project Group
|
||||
Author mh <mh@immerda.ch>
|
||||
Modified by Nicolas Zin <nicolas.zin@savoirfairelinux.com>
|
||||
Licence: GPL v2
|
|
@ -1,7 +0,0 @@
|
|||
require 'rake'
|
||||
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec) do |t|
|
||||
t.pattern = 'spec/*/*_spec.rb'
|
||||
end
|
|
@ -31,8 +31,7 @@ module Puppet
|
|||
|
||||
newproperty(:target) do
|
||||
desc "Name of the file to store parameters in"
|
||||
defaultto { if @resource.class.defaultprovider and
|
||||
@resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
|
||||
defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
|
||||
@resource.class.defaultprovider.default_target
|
||||
else
|
||||
nil
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# default params for sysctl
|
||||
#
|
||||
# Use this to set default values that are used by this module.
|
||||
#
|
||||
# * exec_path: The path parameter for your exec. Can be handy if you
|
||||
# don't want to set a global exec default.
|
||||
class sysctl::params(
|
||||
$exec_path = undef,
|
||||
) { }
|
|
@ -1,44 +1,35 @@
|
|||
# Manage sysctl value
|
||||
#
|
||||
# It not only manages the entry within
|
||||
# /etc/sysctl.conf, but also checks the
|
||||
# current active version.
|
||||
define sysctl::value (
|
||||
$value,
|
||||
$key = $name,
|
||||
$key = 'name'
|
||||
) {
|
||||
|
||||
$array = split($value,'[\s\t]')
|
||||
$val1 = inline_template("<%= @array.reject(&:empty?).flatten.join(\"\t\") %>")
|
||||
$val1 = inline_template("<%= @array.delete_if(&:empty?).flatten.join(\"\t\") %>")
|
||||
|
||||
sysctl { $key :
|
||||
val => $val1,
|
||||
$real_key = $key ? {
|
||||
'name' => $name,
|
||||
default => $key,
|
||||
}
|
||||
|
||||
sysctl { $real_key :
|
||||
val => $val1,
|
||||
before => Exec["exec_sysctl_${real_key}"],
|
||||
}
|
||||
|
||||
$command = $::kernel ? {
|
||||
/i?BSD$/ => shellquote('sysctl', "${key}=${val1}"),
|
||||
default => shellquote('sysctl','-w',"${key}=${val1}"),
|
||||
openbsd => "sysctl ${real_key}=\"${val1}\"",
|
||||
default => "sysctl -w ${real_key}=\"${val1}\"",
|
||||
}
|
||||
|
||||
$current_value = shellquote(
|
||||
'sysctl',
|
||||
'-n',
|
||||
$key
|
||||
)
|
||||
$unless = $::kernel ? {
|
||||
openbsd => "sysctl ${real_key} | grep -q '=${val1}\$'",
|
||||
default => "sysctl ${real_key} | grep -q ' = ${val1}'",
|
||||
}
|
||||
|
||||
$shellquoted_value = shellquote($val1)
|
||||
$unless = "[ \"\$(${current_value})\" = ${shellquoted_value} ]"
|
||||
|
||||
exec { "exec_sysctl_${key}" :
|
||||
exec { "exec_sysctl_${real_key}" :
|
||||
command => $command,
|
||||
unless => $unless,
|
||||
require => Sysctl[$key],
|
||||
}
|
||||
|
||||
include sysctl::params
|
||||
if $sysctl::params::exec_path {
|
||||
Exec["exec_sysctl_${key}"]{
|
||||
path => $sysctl::params::exec_path
|
||||
}
|
||||
require => Sysctl[$real_key],
|
||||
path => ["/bin", "/sbin", "/usr/bin", "/usr/sbin"],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'sysctl::value' do
|
||||
oses = [
|
||||
{ :osfamily => 'Debian',
|
||||
:operatingsystem => 'debian',
|
||||
:kernel => 'Linux',
|
||||
},
|
||||
{ :osfamily => 'RedHat',
|
||||
:operatingsystem => 'CentOS',
|
||||
:kernel => 'Linux',
|
||||
},
|
||||
{ :osfamily => 'OpenBSD',
|
||||
:operatingsystem => 'OpenBSD',
|
||||
:kernel => 'OpenBSD',
|
||||
},
|
||||
{ :osfamily => 'FreeBSD',
|
||||
:operatingsystem => 'FreeBSD',
|
||||
:kernel => 'FreeBSD',
|
||||
},
|
||||
]
|
||||
let :title do 'rspec_test' end
|
||||
let :params do { :value => 'foo bar baz' } end
|
||||
oses.each { |f|
|
||||
context "on #{f[:operatingsystem]}" do
|
||||
let :facts do f end
|
||||
|
||||
it { should contain_sysctl('rspec_test').with_val(
|
||||
"foo\tbar\tbaz"
|
||||
) }
|
||||
|
||||
# OS-specific traits.
|
||||
case f[:kernel]
|
||||
when 'Linux' then
|
||||
it { should contain_exec('exec_sysctl_rspec_test').with_command(
|
||||
"sysctl -w \"rspec_test=foo\tbar\tbaz\""
|
||||
) }
|
||||
when /BSD$/ then
|
||||
it { should contain_exec('exec_sysctl_rspec_test').with_command(
|
||||
"sysctl \"rspec_test=foo\tbar\tbaz\""
|
||||
) }
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
|
@ -1 +0,0 @@
|
|||
../../../../lib
|
|
@ -1 +0,0 @@
|
|||
../../../../manifests
|
|
@ -1,8 +0,0 @@
|
|||
require 'rspec-puppet'
|
||||
|
||||
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.module_path = File.join(fixture_path, 'modules')
|
||||
c.manifest_dir = File.join(fixture_path, 'manifests')
|
||||
end
|
Loading…
Reference in New Issue