Last active
January 28, 2016 18:45
-
-
Save chadh/2fd3f4d3222fff2a5fea to your computer and use it in GitHub Desktop.
puppet provider for pulp rpm repos.
This file contains hidden or 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
| 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