Skip to content

Instantly share code, notes, and snippets.

@chadh
Last active January 28, 2016 18:45
Show Gist options
  • Select an option

  • Save chadh/2fd3f4d3222fff2a5fea to your computer and use it in GitHub Desktop.

Select an option

Save chadh/2fd3f4d3222fff2a5fea to your computer and use it in GitHub Desktop.
puppet provider for pulp rpm repos.
require 'puppet/type'
require 'uri'
require 'puppet/parameter/boolean'
Puppet::Type.newtype(:pulp_repo) do
desc "Type to manage Pulp repos"
ensurable
newparam(:id, :namevar => true) do
desc "Id of the repo"
validate do |value|
unless value =~ /[[:alnum:]]\w*/
raise ArgumentError, "Repo Id is not valid: #{value}"
end
end
end
newproperty(:feed) do
desc "URL of Repo feed"
validate do |value|
unless value =~ URI.regexp
raise ArgumentError, "feed is not a valid URL: #{value}"
end
end
end
newproperty(:relative_url) do
desc "Relative URL Path of Repo on Pulp server"
validate do |value|
unless value =~ %r{[/\w-]}
raise ArgumentError, "relative_url is not valid: #{value}"
end
end
end
newproperty(:display_name)
newproperty(:description)
# Leaving this out for now, because we don't use it, and there is some
# discrepancy between the json dumps we are using and the pulp-admin repo list
# newproperty(:note) do
# validate do |value|
# raise ArgumentError, 'Note must be a map' unless value.is_a? Hash
# value.each do |k,v|
# unless k =~ /[[:word]]+/
# raise ArgumentError, "Note keys must not contain spaces"
# end
# end
# end
# end
newproperty(:schedules, :array_matching => :all) do
def insync?(is)
if is == nil then
if @should == nil then
return true
end
return false
end
is.sort == @should.sort
end
end
newproperty(:serve_http)
newproperty(:serve_https)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment