Permalink
Browse files

moved stuff to plugins

  • Loading branch information...
duritong committed Jan 6, 2008
0 parents commit 13147197575fc224ec2f17d2484e0feff535ff50
Showing with 63 additions and 0 deletions.
  1. +4 −0 manifests/init.pp
  2. +17 −0 plugins/puppet/provider/sysctl/parsed.rb
  3. +42 −0 plugins/puppet/type/sysctl.rb
@@ -0,0 +1,4 @@
+# sysctl/manifests/init.pp - Define sysctl module stuff
+# Copyright (C) 2008 admin@immerda.ch
+# See LICENSE for the full license granted to you.
+
@@ -0,0 +1,17 @@
+require 'puppet/provider/parsedfile'
+
+sysctlconf = "/etc/sysctl.conf"
+
+Puppet::Type.type(:sysctl).provide(:parsed,
+ :parent => Puppet::Provider::ParsedFile,
+ :default_target => sysctlconf,
+ :filetype => :flat
+ ) do
+
+ confine :exists => sysctlconf
+ text_line :comment, :match => /^#/;
+ text_line :blank, :match => /^\s*$/;
+
+ record_line :parsed, :fields => %w{name val}, :joiner => ' = ', :separator => /\s*=\s*/
+
+end
@@ -0,0 +1,42 @@
+module Puppet
+ newtype(:sysctl) do
+
+ @doc = "Manages kernel parameters in /etc/sysctl.conf. By default this will
+ only edit the configuration file, and not change any of the runtime
+ values. If you wish changes to be activated right away, you can do
+ so with an exec like so:
+
+ exec { load-sysctl:
+ command => \"/sbin/sysctl -p /etc/sysctl.conf\",
+ refreshonly => true
+ }
+
+ Set any changes you want to happen right away to notify this command,
+ or you can set it as the default:
+
+ Sysctl {
+ notify => Exec[load-sysctl]
+ }"
+
+ ensurable
+
+ newparam(:name, :namevar => true) do
+ desc "Name of the parameter"
+ isnamevar
+ end
+
+ newproperty(:val) do
+ desc "Value the parameter should be set to"
+ end
+
+ newproperty(:target) do
+ desc "Name of the file to store parameters in"
+ defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
+ @resource.class.defaultprovider.default_target
+ else
+ nil
+ end
+ }
+ end
+ end
+end

0 comments on commit 1314719

Please sign in to comment.