From 9b0dd8fed5be14f3415d63b8bdc1487fc5a97137 Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Wed, 19 Jul 2017 11:07:27 +0200 Subject: [PATCH] Allow configuration of trust notifier To be able to use the trust notifier, we need to fill the trustee section in the configuration. Change-Id: Ibba7af4983303f3b85aa399f77391ba6bc984e8d --- manifests/init.pp | 1 + manifests/keystone/trust.pp | 51 +++++++++++++++++++++++ spec/classes/zaqar_keystone_trust_spec.rb | 41 ++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 manifests/keystone/trust.pp create mode 100644 spec/classes/zaqar_keystone_trust_spec.rb diff --git a/manifests/init.pp b/manifests/init.pp index 4e3cd1a..f1fb85b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -96,6 +96,7 @@ class zaqar( if $auth_strategy == 'keystone' { include ::zaqar::keystone::authtoken + include ::zaqar::keystone::trust } package { 'zaqar-common': diff --git a/manifests/keystone/trust.pp b/manifests/keystone/trust.pp new file mode 100644 index 0000000..902f891 --- /dev/null +++ b/manifests/keystone/trust.pp @@ -0,0 +1,51 @@ +# == Class: zaqar::keystone::trust +# +# Configures zaqar trust notifier. +# +# === Parameters +# +# [*username*] +# (Optional) The name of the trust user +# Defaults to 'zaqar' +# +# [*password*] +# (Optional) Password to create for the trust user +# Defaults to $::os_service_default +# +# [*auth_url*] +# (Optional) The URL to use for authentication. +# Defaults to 'http://localhost:35357' +# +# [*user_domain_name*] +# (Optional) Name of domain for $username +# Defaults to $::os_service_default +# +# [*auth_section*] +# (Optional) Config Section from which to load plugin specific options +# Defaults to $::os_service_default. +# +# [*auth_type*] +# (Optional) Authentication type to load +# Defaults to 'password' +# +class zaqar::keystone::trust( + $username = 'zaqar', + $password = $::os_service_default, + $auth_url = 'http://localhost:35357', + $user_domain_name = $::os_service_default, + $auth_section = $::os_service_default, + $auth_type = 'password', +) { + + include ::zaqar::deps + + zaqar_config { + 'trustee/username': value => $username; + 'trustee/password': value => $password; + 'trustee/user_domain_name': value => $user_domain_name; + 'trustee/auth_url': value => $auth_url; + 'trustee/auth_section': value => $auth_section; + 'trustee/auth_type': value => $auth_type; + } + +} diff --git a/spec/classes/zaqar_keystone_trust_spec.rb b/spec/classes/zaqar_keystone_trust_spec.rb new file mode 100644 index 0000000..10eef03 --- /dev/null +++ b/spec/classes/zaqar_keystone_trust_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'zaqar::keystone::trust' do + + shared_examples_for 'zaqar::keystone::trust' do + describe 'with custom values' do + let :params do + { + :username => 'user', + :password => 'secret', + :auth_url => 'http://there', + :user_domain_name => 'domain', + :auth_section => 'keystone', + :auth_type => 'token', + } + end + + it 'configures custom values' do + is_expected.to contain_zaqar_config('trustee/username').with_value('user') + is_expected.to contain_zaqar_config('trustee/password').with_value('secret') + is_expected.to contain_zaqar_config('trustee/auth_url').with_value('http://there') + is_expected.to contain_zaqar_config('trustee/user_domain_name').with_value('domain') + is_expected.to contain_zaqar_config('trustee/auth_section').with_value('keystone') + is_expected.to contain_zaqar_config('trustee/auth_type').with_value('token') + end + end + 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 + + it_configures 'zaqar::keystone::trust' + end + end +end +