You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide the option to only update the live value (#15)
There are some sysctl values which, when set in /etc/sysctl.conf, may
cause operational harm to a system.
This patch provides the ability to only update the live value and make
the disk persistence optional.
Additionally:
- Now use prefetching to get the sysctl values
- Updated self.instances to obtain information about all sysctl values
which provides a more accurate representation of the system when using
`puppet resource`
- Fail if the user attempts to set a value that is not valid on the
system unless `silent` is set.
- Updated all tests
- Refactored Travis CI Tests
- Added OpenSUSE support
Closes#14
Copy file name to clipboardExpand all lines: lib/puppet/type/sysctl.rb
+29-6Lines changed: 29 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -15,12 +15,25 @@
15
15
16
16
moduleSysctlValueSync
17
17
definsync?(is)
18
-
ifresource[:apply] == :true
19
-
@live_value=provider.live_value
20
-
equal(should,is)andequal(should,@live_value)
18
+
_is_insync=true
19
+
20
+
ifprovider.valid_resource?(resource[:name])
21
+
ifresource[:apply] == :true
22
+
@live_value=provider.live_value
23
+
24
+
_is_insync=equal(should,@live_value)
25
+
end
26
+
27
+
if_is_insync && (resource[:persist] == :true)
28
+
_is_insync=equal(should,is)
29
+
end
21
30
else
22
-
equal(should,is)
31
+
# We won't get here unless exists? has been short circuited so we can
32
+
# rely on that to raise an approprite error.
33
+
debug("augeasproviders_sysctl: skipping insync? due to invalid resource `#{resource[:name]}`")
23
34
end
35
+
36
+
return_is_insync
24
37
end
25
38
26
39
defchange_to_s(current,new)
@@ -30,15 +43,19 @@ def change_to_s(current, new)
30
43
elsifequal(@live_value,new)
31
44
return"changed configuration value from '#{current}' to '#{new}'"
32
45
else
33
-
return"changed configuration value from '#{current}' to '#{new}' and live value from '#{@live_value}' to '#{new}'"
46
+
ifresource[:persist] == :true
47
+
return"changed configuration value from '#{current}' to '#{new}' and live value from '#{@live_value}' to '#{new}'"
48
+
else
49
+
return"changed live value from '#{@live_value}' to '#{new}'"
50
+
end
34
51
end
35
52
else
36
53
return"changed configuration value from '#{current}' to '#{new}'"
37
54
end
38
55
end
39
56
40
57
defequal(a,b)
41
-
a.gsub(/\s+/,' ') == b.gsub(/\s+/,' ')
58
+
a && b && (a.gsub(/\s+/,' ') == b.gsub(/\s+/,' '))
42
59
end
43
60
end
44
61
@@ -77,6 +94,12 @@ def equal(a, b)
77
94
defaultto(:true)
78
95
end
79
96
97
+
newparam(:persist,:boolean=>true)do
98
+
desc"Persist the value in the on-disk file ($target)."
99
+
newvalues(:true,:false)
100
+
defaultto(:true)
101
+
end
102
+
80
103
newparam(:silent,:boolean=>true)do
81
104
desc"If set, do not report an error if the system key does not exist. This is useful for systems that may need to load a kernel module prior to the sysctl values existing."
0 commit comments