~ubuntu-branches/ubuntu/wily/puppet/wily

« back to all changes in this revision

Viewing changes to lib/puppet/type/yumrepo.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2014-04-17 14:50:28 UTC
  • mfrom: (3.1.59 sid)
  • Revision ID: package-import@ubuntu.com-20140417145028-j3p3dwvp8ggpzvaf
Tags: 3.5.1-1
ImportedĀ upstreamĀ releaseĀ 3.5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'puppet/util/inifile'
2
 
 
3
 
module Puppet
4
 
  # A property for one entry in a .ini-style file
5
 
  class IniProperty < Puppet::Property
6
 
    def insync?(is)
7
 
      # A should property of :absent is the same as nil
8
 
      if is.nil? && should == :absent
9
 
        return true
10
 
      end
11
 
      super(is)
12
 
    end
13
 
 
14
 
    def sync
15
 
      if safe_insync?(retrieve)
16
 
        result = nil
17
 
      else
18
 
        result = set(self.should)
19
 
        if should == :absent
20
 
          resource.section[inikey] = nil
21
 
        else
22
 
          resource.section[inikey] = should
23
 
        end
24
 
      end
25
 
      result
26
 
    end
27
 
 
28
 
    def retrieve
29
 
      resource.section[inikey]
30
 
    end
31
 
 
32
 
    def inikey
33
 
      name.to_s
34
 
    end
35
 
 
36
 
    # Set the key associated with this property to KEY, instead
37
 
    # of using the property's NAME
38
 
    def self.inikey(key)
39
 
      # Override the inikey instance method
40
 
      # Is there a way to do this without resorting to strings ?
41
 
      # Using a block fails because the block can't access
42
 
      # the variable 'key' in the outer scope
43
 
      self.class_eval("def inikey ; \"#{key.to_s}\" ; end")
44
 
    end
45
 
 
46
 
  end
47
 
 
 
1
require 'uri'
 
2
 
 
3
Puppet::Type.newtype(:yumrepo) do
 
4
  @doc = "The client-side description of a yum repository. Repository
 
5
    configurations are found by parsing `/etc/yum.conf` and
 
6
    the files indicated by the `reposdir` option in that file
 
7
    (see `yum.conf(5)` for details).
 
8
 
 
9
    Most parameters are identical to the ones documented
 
10
    in the `yum.conf(5)` man page.
 
11
 
 
12
    Continuation lines that yum supports (for the `baseurl`, for example)
 
13
    are not supported. This type does not attempt to read or verify the
 
14
    exinstence of files listed in the `include` attribute."
 
15
 
 
16
  # Ensure yumrepos can be removed too.
 
17
  ensurable
48
18
  # Doc string for properties that can be made 'absent'
49
19
  ABSENT_DOC="Set this to `absent` to remove it from the file completely."
50
 
 
51
 
  newtype(:yumrepo) do
52
 
    @doc = "The client-side description of a yum repository. Repository
53
 
      configurations are found by parsing `/etc/yum.conf` and
54
 
      the files indicated by the `reposdir` option in that file
55
 
      (see `yum.conf(5)` for details).
56
 
 
57
 
      Most parameters are identical to the ones documented
58
 
      in the `yum.conf(5)` man page.
59
 
 
60
 
      Continuation lines that yum supports (for the `baseurl`, for example)
61
 
      are not supported. This type does not attempt to read or verify the
62
 
      exinstence of files listed in the `include` attribute."
63
 
 
64
 
    class << self
65
 
      attr_accessor :filetype
66
 
      # The writer is only used for testing, there should be no need
67
 
      # to change yumconf or inifile in any other context
68
 
      attr_accessor :yumconf
69
 
      attr_writer :inifile
70
 
    end
71
 
 
72
 
    self.filetype = Puppet::Util::FileType.filetype(:flat)
73
 
 
74
 
    @inifile = nil
75
 
 
76
 
    @yumconf = "/etc/yum.conf"
77
 
 
78
 
    # Where to put files for brand new sections
79
 
    @defaultrepodir = nil
80
 
 
81
 
    def self.instances
82
 
      l = []
83
 
      check = validproperties
84
 
      clear
85
 
      inifile.each_section do |s|
86
 
        next if s.name == "main"
87
 
        obj = new(:name => s.name, :audit => check)
88
 
        current_values = obj.retrieve
89
 
        obj.eachproperty do |property|
90
 
          if current_values[property].nil?
91
 
            obj.delete(property.name)
92
 
          else
93
 
            property.should = current_values[property]
94
 
          end
95
 
        end
96
 
        obj.delete(:audit)
97
 
        l << obj
98
 
      end
99
 
      l
100
 
    end
101
 
 
102
 
    # Return the Puppet::Util::IniConfig::File for the whole yum config
103
 
    def self.inifile
104
 
      if @inifile.nil?
105
 
        @inifile = read
106
 
        main = @inifile['main']
107
 
        raise Puppet::Error, "File #{yumconf} does not contain a main section" if main.nil?
108
 
        reposdir = main['reposdir']
109
 
        reposdir ||= "/etc/yum.repos.d, /etc/yum/repos.d"
110
 
        reposdir.gsub!(/[\n,]/, " ")
111
 
        reposdir.split.each do |dir|
112
 
          Dir::glob("#{dir}/*.repo").each do |file|
113
 
            @inifile.read(file) if ::File.file?(file)
114
 
          end
115
 
        end
116
 
        reposdir.split.each do |dir|
117
 
          if ::File.directory?(dir) && ::File.writable?(dir)
118
 
            @defaultrepodir = dir
119
 
            break
120
 
          end
121
 
        end
122
 
      end
123
 
      @inifile
124
 
    end
125
 
 
126
 
    # Parse the yum config files. Only exposed for the tests
127
 
    # Non-test code should use self.inifile to get at the
128
 
    # underlying file
129
 
    def self.read
130
 
      result = Puppet::Util::IniConfig::File.new
131
 
      result.read(yumconf)
132
 
      main = result['main']
133
 
      raise Puppet::Error, "File #{yumconf} does not contain a main section" if main.nil?
134
 
      reposdir = main['reposdir']
135
 
      reposdir ||= "/etc/yum.repos.d, /etc/yum/repos.d"
136
 
      reposdir.gsub!(/[\n,]/, " ")
137
 
      reposdir.split.each do |dir|
138
 
        Dir::glob("#{dir}/*.repo").each do |file|
139
 
          result.read(file) if ::File.file?(file)
140
 
        end
141
 
      end
142
 
      if @defaultrepodir.nil?
143
 
        reposdir.split.each do |dir|
144
 
          if ::File.directory?(dir) && ::File.writable?(dir)
145
 
            @defaultrepodir = dir
146
 
            break
147
 
          end
148
 
        end
149
 
      end
150
 
      result
151
 
    end
152
 
 
153
 
    # Return the Puppet::Util::IniConfig::Section with name NAME
154
 
    # from the yum config
155
 
    def self.section(name)
156
 
      result = inifile[name]
157
 
      if result.nil?
158
 
        # Brand new section
159
 
        path = yumconf
160
 
        path = ::File.join(@defaultrepodir, "#{name}.repo") unless @defaultrepodir.nil?
161
 
        Puppet::info "create new repo #{name} in file #{path}"
162
 
        result = inifile.add_section(name, path)
163
 
      end
164
 
      result
165
 
    end
166
 
 
167
 
    # Store all modifications back to disk
168
 
    def self.store
169
 
      inifile.store
170
 
      unless Puppet[:noop]
171
 
        target_mode = 0644 # FIXME: should be configurable
172
 
        inifile.each_file do |file|
173
 
          current_mode = Puppet::FileSystem::File.new(file).stat.mode & 0777
174
 
          unless current_mode == target_mode
175
 
            Puppet::info "changing mode of #{file} from %03o to %03o" % [current_mode, target_mode]
176
 
            ::File.chmod(target_mode, file)
177
 
          end
178
 
        end
179
 
      end
180
 
    end
181
 
 
182
 
    # This is only used during testing.
183
 
    def self.clear
184
 
      @inifile = nil
185
 
      @yumconf = "/etc/yum.conf"
186
 
      @defaultrepodir = nil
187
 
    end
188
 
 
189
 
    # Return the Puppet::Util::IniConfig::Section for this yumrepo resource
190
 
    def section
191
 
      self.class.section(self[:name])
192
 
    end
193
 
 
194
 
    # Store modifications to this yumrepo resource back to disk
195
 
    def flush
196
 
      self.class.store
197
 
    end
198
 
 
199
 
    newparam(:name) do
200
 
      desc "The name of the repository.  This corresponds to the
201
 
        `repositoryid` parameter in `yum.conf(5)`."
202
 
      isnamevar
203
 
    end
204
 
 
205
 
    newproperty(:descr, :parent => Puppet::IniProperty) do
206
 
      desc "A human-readable description of the repository.
207
 
        This corresponds to the name parameter in `yum.conf(5)`.
208
 
        #{ABSENT_DOC}"
209
 
      newvalue(:absent) { self.should = :absent }
210
 
      newvalue(/.*/) { }
211
 
      inikey "name"
212
 
    end
213
 
 
214
 
    newproperty(:mirrorlist, :parent => Puppet::IniProperty) do
215
 
      desc "The URL that holds the list of mirrors for this repository.
216
 
        #{ABSENT_DOC}"
217
 
      newvalue(:absent) { self.should = :absent }
218
 
      # Should really check that it's a valid URL
219
 
      newvalue(/.*/) { }
220
 
    end
221
 
 
222
 
    newproperty(:baseurl, :parent => Puppet::IniProperty) do
223
 
      desc "The URL for this repository. #{ABSENT_DOC}"
224
 
      newvalue(:absent) { self.should = :absent }
225
 
      # Should really check that it's a valid URL
226
 
      newvalue(/.*/) { }
227
 
    end
228
 
 
229
 
    newproperty(:enabled, :parent => Puppet::IniProperty) do
230
 
      desc "Whether this repository is enabled, as represented by a
231
 
        `0` or `1`. #{ABSENT_DOC}"
232
 
      newvalue(:absent) { self.should = :absent }
233
 
      newvalue(/^(0|1)$/) { }
234
 
    end
235
 
 
236
 
    newproperty(:gpgcheck, :parent => Puppet::IniProperty) do
237
 
      desc "Whether to check the GPG signature on packages installed
238
 
        from this repository, as represented by a `0` or `1`.
239
 
        #{ABSENT_DOC}"
240
 
      newvalue(:absent) { self.should = :absent }
241
 
      newvalue(/^(0|1)$/) { }
242
 
    end
243
 
 
244
 
    newproperty(:gpgkey, :parent => Puppet::IniProperty) do
245
 
      desc "The URL for the GPG key with which packages from this
246
 
        repository are signed. #{ABSENT_DOC}"
247
 
      newvalue(:absent) { self.should = :absent }
248
 
      # Should really check that it's a valid URL
249
 
      newvalue(/.*/) { }
250
 
    end
251
 
 
252
 
    newproperty(:include, :parent => Puppet::IniProperty) do
253
 
      desc "The URL of a remote file containing additional yum configuration
254
 
        settings. Puppet does not check for this file's existence or validity.
255
 
        #{ABSENT_DOC}"
256
 
      newvalue(:absent) { self.should = :absent }
257
 
      # Should really check that it's a valid URL
258
 
      newvalue(/.*/) { }
259
 
    end
260
 
 
261
 
    newproperty(:exclude, :parent => Puppet::IniProperty) do
262
 
      desc "List of shell globs. Matching packages will never be
263
 
        considered in updates or installs for this repo.
264
 
        #{ABSENT_DOC}"
265
 
      newvalue(:absent) { self.should = :absent }
266
 
      newvalue(/.*/) { }
267
 
    end
268
 
 
269
 
    newproperty(:includepkgs, :parent => Puppet::IniProperty) do
270
 
      desc "List of shell globs. If this is set, only packages
271
 
        matching one of the globs will be considered for
272
 
        update or install from this repo. #{ABSENT_DOC}"
273
 
      newvalue(:absent) { self.should = :absent }
274
 
      newvalue(/.*/) { }
275
 
    end
276
 
 
277
 
    newproperty(:enablegroups, :parent => Puppet::IniProperty) do
278
 
      desc "Whether yum will allow the use of package groups for this
279
 
        repository, as represented by a `0` or `1`. #{ABSENT_DOC}"
280
 
      newvalue(:absent) { self.should = :absent }
281
 
      newvalue(/^(0|1)$/) { }
282
 
    end
283
 
 
284
 
    newproperty(:failovermethod, :parent => Puppet::IniProperty) do
285
 
      desc "The failover methode for this repository; should be either
286
 
        `roundrobin` or `priority`. #{ABSENT_DOC}"
287
 
      newvalue(:absent) { self.should = :absent }
288
 
      newvalue(%r{roundrobin|priority}) { }
289
 
    end
290
 
 
291
 
    newproperty(:keepalive, :parent => Puppet::IniProperty) do
292
 
      desc "Whether HTTP/1.1 keepalive should be used with this repository, as
293
 
        represented by a `0` or `1`. #{ABSENT_DOC}"
294
 
      newvalue(:absent) { self.should = :absent }
295
 
      newvalue(/^(0|1)$/) { }
296
 
    end
297
 
 
298
 
     newproperty(:http_caching, :parent => Puppet::IniProperty) do
299
 
       desc "What to cache from this repository. #{ABSENT_DOC}"
300
 
       newvalue(:absent) { self.should = :absent }
301
 
       newvalue(%r(packages|all|none)) { }
302
 
     end
303
 
 
304
 
    newproperty(:timeout, :parent => Puppet::IniProperty) do
305
 
      desc "Number of seconds to wait for a connection before timing
306
 
        out. #{ABSENT_DOC}"
307
 
      newvalue(:absent) { self.should = :absent }
308
 
      newvalue(%r{[0-9]+}) { }
309
 
    end
310
 
 
311
 
    newproperty(:metadata_expire, :parent => Puppet::IniProperty) do
312
 
      desc "Number of seconds after which the metadata will expire.
313
 
        #{ABSENT_DOC}"
314
 
      newvalue(:absent) { self.should = :absent }
315
 
      newvalue(%r{[0-9]+}) { }
316
 
    end
317
 
 
318
 
    newproperty(:protect, :parent => Puppet::IniProperty) do
319
 
      desc "Enable or disable protection for this repository. Requires
320
 
        that the `protectbase` plugin is installed and enabled.
321
 
        #{ABSENT_DOC}"
322
 
      newvalue(:absent) { self.should = :absent }
323
 
      newvalue(/^(0|1)$/) { }
324
 
    end
325
 
 
326
 
    newproperty(:priority, :parent => Puppet::IniProperty) do
327
 
      desc "Priority of this repository from 1-99. Requires that
328
 
        the `priorities` plugin is installed and enabled.
329
 
        #{ABSENT_DOC}"
330
 
      newvalue(:absent) { self.should = :absent }
331
 
      newvalue(%r{[1-9][0-9]?}) { }
332
 
    end
333
 
 
334
 
    newproperty(:cost, :parent => Puppet::IniProperty) do
335
 
      desc "Cost of this repository. #{ABSENT_DOC}"
336
 
      newvalue(:absent) { self.should = :absent }
337
 
      newvalue(%r{\d+}) { }
338
 
    end
339
 
 
340
 
    newproperty(:proxy, :parent => Puppet::IniProperty) do
341
 
      desc "URL to the proxy server for this repository. #{ABSENT_DOC}"
342
 
      newvalue(:absent) { self.should = :absent }
343
 
      # Should really check that it's a valid URL
344
 
      newvalue(/.*/) { }
345
 
    end
346
 
 
347
 
    newproperty(:proxy_username, :parent => Puppet::IniProperty) do
348
 
      desc "Username for this proxy. #{ABSENT_DOC}"
349
 
      newvalue(:absent) { self.should = :absent }
350
 
      newvalue(/.*/) { }
351
 
    end
352
 
 
353
 
    newproperty(:proxy_password, :parent => Puppet::IniProperty) do
354
 
      desc "Password for this proxy. #{ABSENT_DOC}"
355
 
      newvalue(:absent) { self.should = :absent }
356
 
      newvalue(/.*/) { }
357
 
    end
358
 
 
359
 
    newproperty(:s3_enabled, :parent => Puppet::IniProperty) do
360
 
      desc "Access the repo via S3. #{ABSENT_DOC}"
361
 
      newvalue(:absent) { self.should = :absent }
362
 
      newvalue(/^(0|1)$/) { }
363
 
    end
364
 
 
365
 
    newproperty(:sslcacert, :parent => Puppet::IniProperty) do
366
 
      desc "Path to the directory containing the databases of the
367
 
        certificate authorities yum should use to verify SSL certificates.
368
 
        #{ABSENT_DOC}"
369
 
      newvalue(:absent) { self.should = :absent }
370
 
      newvalue(/.*/) { }
371
 
    end
372
 
 
373
 
    newproperty(:sslverify, :parent => Puppet::IniProperty) do
374
 
      desc "Should yum verify SSL certificates/hosts at all.
375
 
        Possible values are 'True' or 'False'.
376
 
        #{ABSENT_DOC}"
377
 
      newvalue(:absent) { self.should = :absent }
378
 
      newvalue(%r(True|False)) { }
379
 
    end
380
 
 
381
 
    newproperty(:sslclientcert, :parent => Puppet::IniProperty) do
382
 
      desc "Path  to the SSL client certificate yum should use to connect
383
 
        to repos/remote sites. #{ABSENT_DOC}"
384
 
      newvalue(:absent) { self.should = :absent }
385
 
      newvalue(/.*/) { }
386
 
    end
387
 
 
388
 
    newproperty(:sslclientkey, :parent => Puppet::IniProperty) do
389
 
      desc "Path to the SSL client key yum should use to connect
390
 
        to repos/remote sites. #{ABSENT_DOC}"
391
 
      newvalue(:absent) { self.should = :absent }
392
 
      newvalue(/.*/) { }
393
 
    end
394
 
  end
 
20
  # False can be false/0/no and True can be true/1/yes in yum.
 
21
  YUM_BOOLEAN=/(True|False|0|1|No|Yes)/i
 
22
  YUM_BOOLEAN_DOC="Valid values are: False/0/No or True/1/Yes."
 
23
 
 
24
  VALID_SCHEMES = %w[file http https ftp]
 
25
 
 
26
  newparam(:name, :namevar => true) do
 
27
    desc "The name of the repository.  This corresponds to the
 
28
     `repositoryid` parameter in `yum.conf(5)`."
 
29
  end
 
30
 
 
31
  newparam(:target) do
 
32
    desc "The filename to write the yum repository to."
 
33
 
 
34
    defaultto :absent
 
35
  end
 
36
 
 
37
  newproperty(:descr) do
 
38
    desc "A human-readable description of the repository.
 
39
      This corresponds to the name parameter in `yum.conf(5)`.
 
40
      #{ABSENT_DOC}"
 
41
 
 
42
    newvalues(/.*/, :absent)
 
43
  end
 
44
 
 
45
  newproperty(:mirrorlist) do
 
46
    desc "The URL that holds the list of mirrors for this repository.
 
47
      #{ABSENT_DOC}"
 
48
 
 
49
    newvalues(/.*/, :absent)
 
50
    validate do |value|
 
51
      next if value.to_s == 'absent'
 
52
      parsed = URI.parse(value)
 
53
 
 
54
      unless VALID_SCHEMES.include?(parsed.scheme)
 
55
        raise "Must be a valid URL"
 
56
      end
 
57
    end
 
58
  end
 
59
 
 
60
  newproperty(:baseurl) do
 
61
    desc "The URL for this repository. #{ABSENT_DOC}"
 
62
 
 
63
    newvalues(/.*/, :absent)
 
64
    validate do |value|
 
65
      next if value.to_s == 'absent'
 
66
 
 
67
      value.split(/\s+/).each do |uri|
 
68
 
 
69
        parsed = URI.parse(uri)
 
70
 
 
71
        unless VALID_SCHEMES.include?(parsed.scheme)
 
72
          raise "Must be a valid URL"
 
73
        end
 
74
      end
 
75
    end
 
76
  end
 
77
 
 
78
  newproperty(:enabled) do
 
79
    desc "Whether this repository is enabled.
 
80
    #{YUM_BOOLEAN_DOC}
 
81
    #{ABSENT_DOC}"
 
82
 
 
83
    newvalues(YUM_BOOLEAN, :absent)
 
84
  end
 
85
 
 
86
  newproperty(:gpgcheck) do
 
87
    desc "Whether to check the GPG signature on packages installed
 
88
      from this repository.
 
89
      #{YUM_BOOLEAN_DOC}
 
90
      #{ABSENT_DOC}"
 
91
 
 
92
    newvalues(YUM_BOOLEAN, :absent)
 
93
  end
 
94
 
 
95
  newproperty(:repo_gpgcheck) do
 
96
    desc "Whether to check the GPG signature on repodata.
 
97
      #{YUM_BOOLEAN_DOC}
 
98
      #{ABSENT_DOC}"
 
99
 
 
100
    newvalues(YUM_BOOLEAN, :absent)
 
101
  end
 
102
 
 
103
  newproperty(:gpgkey) do
 
104
    desc "The URL for the GPG key with which packages from this
 
105
      repository are signed. #{ABSENT_DOC}"
 
106
 
 
107
    newvalues(/.*/, :absent)
 
108
    validate do |value|
 
109
      next if value.to_s == 'absent'
 
110
 
 
111
      value.split(/\s+/).each do |uri|
 
112
 
 
113
        parsed = URI.parse(uri)
 
114
 
 
115
        unless VALID_SCHEMES.include?(parsed.scheme)
 
116
          raise "Must be a valid URL"
 
117
        end
 
118
      end
 
119
    end
 
120
  end
 
121
 
 
122
  newproperty(:include) do
 
123
    desc "The URL of a remote file containing additional yum configuration
 
124
      settings. Puppet does not check for this file's existence or validity.
 
125
      #{ABSENT_DOC}"
 
126
 
 
127
    newvalues(/.*/, :absent)
 
128
    validate do |value|
 
129
      next if value.to_s == 'absent'
 
130
      parsed = URI.parse(value)
 
131
 
 
132
      unless VALID_SCHEMES.include?(parsed.scheme)
 
133
        raise "Must be a valid URL"
 
134
      end
 
135
    end
 
136
  end
 
137
 
 
138
  newproperty(:exclude) do
 
139
    desc "List of shell globs. Matching packages will never be
 
140
      considered in updates or installs for this repo.
 
141
      #{ABSENT_DOC}"
 
142
 
 
143
    newvalues(/.*/, :absent)
 
144
  end
 
145
 
 
146
  newproperty(:includepkgs) do
 
147
    desc "List of shell globs. If this is set, only packages
 
148
      matching one of the globs will be considered for
 
149
      update or install from this repo. #{ABSENT_DOC}"
 
150
 
 
151
    newvalues(/.*/, :absent)
 
152
  end
 
153
 
 
154
  newproperty(:enablegroups) do
 
155
    desc "Whether yum will allow the use of package groups for this
 
156
      repository.
 
157
      #{YUM_BOOLEAN_DOC}
 
158
      #{ABSENT_DOC}"
 
159
 
 
160
    newvalues(YUM_BOOLEAN, :absent)
 
161
  end
 
162
 
 
163
  newproperty(:failovermethod) do
 
164
    desc "The failover method for this repository; should be either
 
165
      `roundrobin` or `priority`. #{ABSENT_DOC}"
 
166
 
 
167
    newvalues(/roundrobin|priority/, :absent)
 
168
  end
 
169
 
 
170
  newproperty(:keepalive) do
 
171
    desc "Whether HTTP/1.1 keepalive should be used with this repository.
 
172
      #{YUM_BOOLEAN_DOC}
 
173
      #{ABSENT_DOC}"
 
174
 
 
175
    newvalues(YUM_BOOLEAN, :absent)
 
176
  end
 
177
 
 
178
  newproperty(:http_caching) do
 
179
    desc "What to cache from this repository. #{ABSENT_DOC}"
 
180
 
 
181
    newvalues(/(packages|all|none)/, :absent)
 
182
  end
 
183
 
 
184
  newproperty(:timeout) do
 
185
    desc "Number of seconds to wait for a connection before timing
 
186
      out. #{ABSENT_DOC}"
 
187
 
 
188
    newvalues(/[0-9]+/, :absent)
 
189
  end
 
190
 
 
191
  newproperty(:metadata_expire) do
 
192
    desc "Number of seconds after which the metadata will expire.
 
193
      #{ABSENT_DOC}"
 
194
 
 
195
    newvalues(/[0-9]+/, :absent)
 
196
  end
 
197
 
 
198
  newproperty(:protect) do
 
199
    desc "Enable or disable protection for this repository. Requires
 
200
      that the `protectbase` plugin is installed and enabled.
 
201
      #{YUM_BOOLEAN_DOC}
 
202
      #{ABSENT_DOC}"
 
203
 
 
204
    newvalues(YUM_BOOLEAN, :absent)
 
205
  end
 
206
 
 
207
  newproperty(:priority) do
 
208
    desc "Priority of this repository from 1-99. Requires that
 
209
      the `priorities` plugin is installed and enabled.
 
210
      #{ABSENT_DOC}"
 
211
 
 
212
    newvalues(/.*/, :absent)
 
213
    validate do |value|
 
214
      unless value == :absent or (1..99).include?(value.to_i)
 
215
        fail("Must be within range 1-99")
 
216
      end
 
217
    end
 
218
  end
 
219
 
 
220
  newproperty(:cost) do
 
221
    desc "Cost of this repository. #{ABSENT_DOC}"
 
222
 
 
223
    newvalues(/\d+/, :absent)
 
224
  end
 
225
 
 
226
  newproperty(:proxy) do
 
227
    desc "URL to the proxy server for this repository. #{ABSENT_DOC}"
 
228
 
 
229
    newvalues(/.*/, :absent)
 
230
    validate do |value|
 
231
      next if value.to_s == 'absent'
 
232
      parsed = URI.parse(value)
 
233
 
 
234
      unless VALID_SCHEMES.include?(parsed.scheme)
 
235
        raise "Must be a valid URL"
 
236
      end
 
237
    end
 
238
  end
 
239
 
 
240
  newproperty(:proxy_username) do
 
241
    desc "Username for this proxy. #{ABSENT_DOC}"
 
242
 
 
243
    newvalues(/.*/, :absent)
 
244
  end
 
245
 
 
246
  newproperty(:proxy_password) do
 
247
    desc "Password for this proxy. #{ABSENT_DOC}"
 
248
 
 
249
    newvalues(/.*/, :absent)
 
250
  end
 
251
 
 
252
  newproperty(:s3_enabled) do
 
253
    desc "Access the repo via S3.
 
254
      #{YUM_BOOLEAN_DOC}
 
255
      #{ABSENT_DOC}"
 
256
 
 
257
    newvalues(YUM_BOOLEAN, :absent)
 
258
  end
 
259
 
 
260
  newproperty(:sslcacert) do
 
261
    desc "Path to the directory containing the databases of the
 
262
      certificate authorities yum should use to verify SSL certificates.
 
263
      #{ABSENT_DOC}"
 
264
 
 
265
    newvalues(/.*/, :absent)
 
266
  end
 
267
 
 
268
  newproperty(:sslverify) do
 
269
    desc "Should yum verify SSL certificates/hosts at all.
 
270
      #{YUM_BOOLEAN_DOC}
 
271
      #{ABSENT_DOC}"
 
272
 
 
273
    newvalues(YUM_BOOLEAN, :absent)
 
274
  end
 
275
 
 
276
  newproperty(:sslclientcert) do
 
277
    desc "Path  to the SSL client certificate yum should use to connect
 
278
      to repos/remote sites. #{ABSENT_DOC}"
 
279
 
 
280
    newvalues(/.*/, :absent)
 
281
  end
 
282
 
 
283
  newproperty(:sslclientkey) do
 
284
    desc "Path to the SSL client key yum should use to connect
 
285
      to repos/remote sites. #{ABSENT_DOC}"
 
286
 
 
287
    newvalues(/.*/, :absent)
 
288
  end
 
289
 
 
290
  newproperty(:metalink) do
 
291
    desc "Metalink for mirrors. #{ABSENT_DOC}"
 
292
 
 
293
    newvalues(/.*/, :absent)
 
294
    validate do |value|
 
295
      next if value.to_s == 'absent'
 
296
      parsed = URI.parse(value)
 
297
 
 
298
      unless VALID_SCHEMES.include?(parsed.scheme)
 
299
        raise "Must be a valid URL"
 
300
      end
 
301
    end
 
302
  end
 
303
 
395
304
end