Debian Codegraph @

lib/puppet/type/ceph_config.rb

raw
1 # Copyright (C) Dan Bode <[email protected]>
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 # Author: Dan Bode <[email protected]>
16 # Author: Mathieu Gagne <mgagne>
17
18
19 Puppet::Type.newtype(:ceph_config) do
20
21 ensurable
22
23 newparam(:name, :namevar => true) do
24 desc 'Section/setting name to manage from ./ceph.conf'
25 newvalues(/\S+\/\S+/)
26 end
27
28 # required in order to be able to unit test file contents
29 # Note: purge will not work on over-ridden file_path
30 # lifted from ini_file
31 newparam(:path) do
32 desc 'A file path to over ride the default file path if necessary'
33 validate do |value|
34 unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
35 raise(Puppet::Error, "File paths must be fully qualified, not '#{value}'")
36 end
37 end
38 defaultto false
39 end
40
41 newproperty(:value) do
42 desc 'The value of the setting to be defined.'
43 munge do |value|
44 value = value.to_s.strip
45 value.downcase! if value =~ /^(true|false)$/i
46 value
47 end
48 end
49 end