Add module deployment
This commit is contained in:
parent
5aa065c999
commit
2c2db8bd5c
2 changed files with 197 additions and 0 deletions
63
manifests/mod/deployment.pp
Normal file
63
manifests/mod/deployment.pp
Normal file
|
@ -0,0 +1,63 @@
|
|||
# == Class icingaweb2::mod::deployment
|
||||
#
|
||||
class icingaweb2::mod::deployment (
|
||||
$auth_token,
|
||||
$git_repo = 'https://github.com/Thomas-Gelf/icingaweb2-module-deployment.git',
|
||||
$git_revision = undef,
|
||||
$install_method = 'git',
|
||||
$pkg_deps = undef,
|
||||
$pkg_ensure = 'present',
|
||||
$web_root = $::icingaweb2::params::web_root,
|
||||
) {
|
||||
require ::icingaweb2
|
||||
|
||||
validate_absolute_path($web_root)
|
||||
validate_re($install_method,
|
||||
[
|
||||
'git',
|
||||
'package',
|
||||
]
|
||||
)
|
||||
|
||||
File {
|
||||
require => Class['::icingaweb2::config'],
|
||||
owner => $::icingaweb2::config_user,
|
||||
group => $::icingaweb2::config_group,
|
||||
mode => $::icingaweb2::config_file_mode,
|
||||
}
|
||||
|
||||
file { "${web_root}/modules/deployment":
|
||||
ensure => directory,
|
||||
mode => $::icingaweb2::config_dir_mode;
|
||||
}
|
||||
|
||||
if $install_method == 'git' {
|
||||
if $pkg_deps {
|
||||
package { $pkg_deps:
|
||||
ensure => $pkg_ensure,
|
||||
before => Vcsrepo['deployment'],
|
||||
}
|
||||
}
|
||||
|
||||
vcsrepo { 'deployment':
|
||||
ensure => present,
|
||||
path => "${web_root}/modules/deployment",
|
||||
provider => 'git',
|
||||
revision => $git_revision,
|
||||
source => $git_repo,
|
||||
}
|
||||
}
|
||||
|
||||
Ini_Setting {
|
||||
ensure => present,
|
||||
require => File["${::icingaweb2::config_dir}/modules/deployment"],
|
||||
path => "${::icingaweb2::config_dir}/modules/deployment/config.ini",
|
||||
}
|
||||
|
||||
ini_setting { 'deployment auth token':
|
||||
section => 'auth',
|
||||
setting => 'token',
|
||||
value => $auth_token,
|
||||
}
|
||||
}
|
||||
|
134
spec/classes/icingaweb2_mod_deployment_spec.rb
Normal file
134
spec/classes/icingaweb2_mod_deployment_spec.rb
Normal file
|
@ -0,0 +1,134 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'icingaweb2::mod::deployment', :type => :class do
|
||||
let (:pre_condition) { '$concat_basedir = "/tmp"' }
|
||||
let (:facts) { debian_facts }
|
||||
|
||||
let :pre_condition do
|
||||
'include ::icingaweb2'
|
||||
end
|
||||
|
||||
describe 'without parameters' do
|
||||
it { should_not compile }
|
||||
end
|
||||
|
||||
describe 'with parameter: auth_token' do
|
||||
let (:params) {
|
||||
{
|
||||
:auth_token => '_auth_token_'
|
||||
}
|
||||
}
|
||||
|
||||
it { should create_class('icingaweb2::mod::deployment') }
|
||||
it { should contain_file('/usr/share/icingaweb2/modules/deployment') }
|
||||
it { should contain_vcsrepo('deployment') }
|
||||
|
||||
it { should contain_ini_setting('deployment auth token').with(
|
||||
'section' => /auth/,
|
||||
'setting' => /token/,
|
||||
'value' => /_auth_token_/
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with parameter: git_repo' do
|
||||
let (:params) {
|
||||
{
|
||||
:auth_token => 'token',
|
||||
:install_method => 'git',
|
||||
:git_repo => '_git_repo_'
|
||||
}
|
||||
}
|
||||
|
||||
it {
|
||||
should contain_vcsrepo('deployment').with(
|
||||
'path' => /modules\/deployment$/
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with parameter: git_revision' do
|
||||
let (:params) {
|
||||
{
|
||||
:auth_token => 'token',
|
||||
:install_method => 'git',
|
||||
:git_revision => '_git_revision_'
|
||||
}
|
||||
}
|
||||
|
||||
it {
|
||||
should contain_vcsrepo('deployment').with(
|
||||
'revision' => /_git_revision_/
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with parameter: install_method' do
|
||||
describe 'install_method => git' do
|
||||
let (:params) {
|
||||
{
|
||||
:auth_token => 'token',
|
||||
:install_method => 'git'
|
||||
}
|
||||
}
|
||||
|
||||
it { should contain_vcsrepo('deployment') }
|
||||
end
|
||||
|
||||
describe 'install_method => package' do
|
||||
pending
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with parameter: pkg_deps' do
|
||||
describe 'install_method => git' do
|
||||
let (:params) {
|
||||
{
|
||||
:auth_token => 'token',
|
||||
:pkg_deps => '_pkg_deps_'
|
||||
}
|
||||
}
|
||||
|
||||
it { should contain_package('_pkg_deps_').with(
|
||||
'ensure' => 'present'
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
describe 'install_method => package' do
|
||||
pending
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with parameter: pkg_ensure' do
|
||||
describe 'install_method => git' do
|
||||
let (:params) {
|
||||
{
|
||||
:auth_token => 'token',
|
||||
:pkg_deps => '_pkg_deps_',
|
||||
:pkg_ensure => '_pkg_ensure_'
|
||||
}
|
||||
}
|
||||
|
||||
it { should contain_package('_pkg_deps_').with(
|
||||
'ensure' => '_pkg_ensure_'
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
describe 'install_method => package' do
|
||||
pending
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with parameter: web_root' do
|
||||
let (:params) {
|
||||
{
|
||||
:auth_token => 'token',
|
||||
:web_root => '/web/root'
|
||||
}
|
||||
}
|
||||
|
||||
it { should contain_file('/web/root/modules/deployment') }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue