Created
June 14, 2013 19:16
-
-
Save jhoblitt/5784451 to your computer and use it in GitHub Desktop.
augeasprovides / puppet-sysctl conflict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notice: /File[/var/lib/puppet/lib/puppet/type/sysctl.rb]/content: | |
--- /var/lib/puppet/lib/puppet/type/sysctl.rb 2013-02-26 18:58:23.383939334 -0700 | |
+++ /tmp/puppet-file20130614-14008-1qj3tvy-0 2013-06-14 12:07:40.800470828 -0700 | |
@@ -1,42 +1,65 @@ | |
-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 | |
+# Manages entries in /etc/sysctl.conf | |
+# | |
+# Copyright (c) 2012 Dominic Cleal | |
+# Licensed under the Apache License, Version 2.0 | |
+ | |
+Puppet::Type.newtype(:sysctl) do | |
+ @doc = "Manages entries in /etc/sysctl.conf." | |
+ | |
+ ensurable | |
+ | |
+ newparam(:name) do | |
+ desc "The name of the setting, e.g. net.ipv4.ip_forward" | |
+ isnamevar | |
+ end | |
+ | |
+ module SysctlValueSync | |
+ def insync?(is) | |
+ if resource[:apply] == :true | |
+ @live_value = provider.live_value | |
+ should == is and should == @live_value | |
+ else | |
+ should == is | |
+ end | |
+ 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 | |
- } | |
+ def change_to_s(current, new) | |
+ if resource[:apply] == :true | |
+ if current == new | |
+ return "changed live value from '#{@live_value}' to '#{new}'" | |
+ elsif @live_value == new | |
+ return "changed configuration value from '#{current}' to '#{new}'" | |
+ else | |
+ return "changed configuration value from '#{current}' to '#{new}' and live value from '#{@live_value}' to '#{new}'" | |
end | |
+ else | |
+ return "changed configuration value from '#{current}' to '#{new}'" | |
+ end | |
end | |
+ end | |
+ | |
+ newproperty(:val) do | |
+ desc "An alias for 'value'. Maintains interface compatibility with the traditional ParsedFile sysctl provider. If both are set, 'value' will take precedence over 'val'." | |
+ include SysctlValueSync | |
+ end | |
+ | |
+ newproperty(:value) do | |
+ desc "Value to change the setting to. Settings with multiple values (such as net.ipv4.tcp_mem) are represented as a single whitespace separated string." | |
+ include SysctlValueSync | |
+ end | |
+ | |
+ newparam(:target) do | |
+ desc "The file in which to store the settings, defaults to | |
+ `/etc/sysctl.conf`." | |
+ end | |
+ | |
+ newproperty(:comment) do | |
+ desc "Text to be stored in a comment immediately above the entry. It will be automatically prepended with the name of the setting in order for the provider to know whether it controls the comment or not." | |
+ end | |
+ | |
+ newparam(:apply, :boolean => true) do | |
+ desc "Whether to apply the value using the sysctl command." | |
+ newvalues(:true, :false) | |
+ defaultto(true) | |
+ end | |
end | |
Notice: /File[/var/lib/puppet/lib/puppet/type/sysctl.rb]/content: content changed '{md5}65fe3deaf4e245b7a5f031dac3d73f4d' to '{md5}13c80d407531ade6da2a9a48f7097a60' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment