Add rally_deployment as custom resource

This allows the possibility to add new deployments
in rally via puppet

Change-Id: I0a84f5a77bb5ecaa9e8dcde0d17934af658fc5ca
This commit is contained in:
Luis Pigueiras 2017-05-18 15:37:04 +02:00
parent 894d19021f
commit 80ad079e29
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,23 @@
Puppet::Type.type(:rally_deployment).provide(:file) do
commands :rally => "/usr/bin/rally"
def exists?
result = rally "deployment", "list"
result.include? resource[:name]
end
def create
rally "deployment", "create", "--name", resource[:name], "--filename",
resource[:filename]
end
def destroy
rally "deployment", "destroy", resource[:name]
end
def recreate
rally "deployment", "recreate", "--deployment", resource[:name], "--filename",
resource[:filename]
end
end

View File

@ -0,0 +1,41 @@
Puppet::Type.newtype(:rally_deployment, :self_refresh => true) do
@doc = <<-EOS
This type provides Puppet with the capabilities to
create new deployments in rally. It requires to use an
existing file previously defined.
rally_deployment { 'deployment_name':
filename => '/path/to/rally/deployment.json',
}
It will create a deployment called `deployment_name` with
the configuration defined in `/path/to/rally/deployment.json`.
EOS
feature :refreshable, "The provider can recreate the deployment",
:methods => [:recreate]
ensurable do
defaultvalues
defaultto :present
end
newparam(:name) do
desc 'Name for the rally deployment'
end
newparam(:filename) do
desc 'The deployment configuration. It has to be an existing machine'
validate do |value|
unless Puppet::Util.absolute_path?(value)
raise Puppet::Error, "File paths must be fully qualified, not '#{value}'"
end
end
end
def refresh
provider.recreate
end
end