add class to configure influxdb storage configuration
Change-Id: Ifc51a30f0cb03b1f5b79d70bd1ac396850264828
This commit is contained in:
52
manifests/storage/influxdb.pp
Normal file
52
manifests/storage/influxdb.pp
Normal file
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Class to configure influxdb storage
|
||||
#
|
||||
# == Parameters
|
||||
#
|
||||
# [*username*]
|
||||
# InfluxDB username (string value)
|
||||
# [*password*]
|
||||
# InfluxDB password (string value)
|
||||
# [*database*]
|
||||
# InfluxDB database (string value)
|
||||
# [*retention_policy*]
|
||||
# Retention policy to use (string value)
|
||||
# [*host*]
|
||||
# InfluxDB host (string value)
|
||||
# [*port*]
|
||||
# InfluxDB port (integer value)
|
||||
# [*use_ssl*]
|
||||
# Set to true to use ssl for influxDB connection.
|
||||
# (boolean value)
|
||||
# [*insecure*]
|
||||
# Set to true to authorize insecure HTTPS connections to influxDB.
|
||||
# [*cafile*]
|
||||
# Path of the CA certificate to trust for HTTPS
|
||||
# connections (string value)
|
||||
#
|
||||
class cloudkitty::storage::influxdb(
|
||||
String $username = $::os_service_default,
|
||||
String $password = $::os_service_default,
|
||||
String $database = $::os_service_default,
|
||||
String $retention_policy = $::os_service_default,
|
||||
String $host = $::os_service_default,
|
||||
Variant[String[0],Integer] $port = $::os_service_default,
|
||||
Variant[String[0],Boolean] $use_ssl = $::os_service_default,
|
||||
Variant[String[0],Boolean] $insecure = $::os_service_default,
|
||||
String $cafile = $::os_service_default,
|
||||
){
|
||||
|
||||
include cloudkitty::deps
|
||||
|
||||
cloudkitty_config {
|
||||
'storage_influxdb/username': value => $username;
|
||||
'storage_influxdb/password': value => $password, secret => true;
|
||||
'storage_influxdb/database': value => $database;
|
||||
'storage_influxdb/retention_policy': value => $retention_policy;
|
||||
'storage_influxdb/host': value => $host;
|
||||
'storage_influxdb/port': value => $port;
|
||||
'storage_influxdb/use_ssl': value => $use_ssl;
|
||||
'storage_influxdb/insecure': value => $insecure;
|
||||
'storage_influxdb/cafile': value => $cafile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
features:
|
||||
- add class cloudkitty::storage::influxdb to configure influxdb storage
|
||||
63
spec/classes/cloudkitty_storage_influxdb_spec.rb
Normal file
63
spec/classes/cloudkitty_storage_influxdb_spec.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cloudkitty::storage::influxdb' do
|
||||
|
||||
let :params do
|
||||
{ :username => '<SERVICE DEFAULT>',
|
||||
:password => '<SERVICE DEFAULT>',
|
||||
:database => '<SERVICE DEFAULT>',
|
||||
:retention_policy => '<SERVICE DEFAULT>',
|
||||
:host => '<SERVICE DEFAULT>',
|
||||
:port => '<SERVICE DEFAULT>',
|
||||
:use_ssl => '<SERVICE DEFAULT>',
|
||||
:insecure => '<SERVICE DEFAULT>',
|
||||
:cafile => '<SERVICE DEFAULT>',
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
shared_examples_for 'cloudkitty::storage::influxdb' do
|
||||
it { should contain_class('cloudkitty::deps') }
|
||||
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/username').with_value( params[:username])}
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/password').with( value: params[:password], secret: true)}
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/database').with_value( params[:database])}
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/retention_policy').with_value( params[:retention_policy])}
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/host').with_value( params[:host])}
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/port').with_value( params[:port])}
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/use_ssl').with_value( params[:use_ssl])}
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/insecure').with_value( params[:insecure])}
|
||||
it { is_expected.to contain_cloudkitty_config('storage_influxdb/cafile').with_value( params[:cafile])}
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
context 'with default parameters' do
|
||||
it_behaves_like 'cloudkitty::storage::influxdb'
|
||||
end
|
||||
|
||||
context 'when overriding parameters' do
|
||||
before do
|
||||
params.merge!({
|
||||
:username => 'kittycloud',
|
||||
:password => 'nice',
|
||||
:database => 'kittycloud',
|
||||
:retention_policy => 'policy',
|
||||
:host => 'kitty.heaven.org',
|
||||
:port => 42,
|
||||
:use_ssl => 'true',
|
||||
:insecure => 'true',
|
||||
:cafile => '/tmp/cafile.crt',
|
||||
})
|
||||
end
|
||||
it_behaves_like 'cloudkitty::storage::influxdb'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user