From 9faccf9cac24d51a8ba140a2e25eb852bbf6d004 Mon Sep 17 00:00:00 2001 From: Brent Eagles Date: Tue, 5 Dec 2017 16:05:31 -0330 Subject: [PATCH] Adding service_auth configuration Adds support for the basic set of 'service_auth' section parameters for Octavia. Change-Id: Ifcd38386db386ee6d61aa7f262b1e14ac6516eb7 --- manifests/service_auth.pp | 50 +++++++++++++++++++ ...e-auth-configuration-f70310c15b15443c.yaml | 4 ++ spec/classes/octavia_service_auth_spec.rb | 49 ++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 manifests/service_auth.pp create mode 100644 releasenotes/notes/add-service-auth-configuration-f70310c15b15443c.yaml create mode 100644 spec/classes/octavia_service_auth_spec.rb diff --git a/manifests/service_auth.pp b/manifests/service_auth.pp new file mode 100644 index 00000000..80223a46 --- /dev/null +++ b/manifests/service_auth.pp @@ -0,0 +1,50 @@ +# +# Configures credentials for service to service communication. +# +# === Parameters: +# +# [*auth_url*] +# (optional) Keystone Authentication URL +# Defaults to $::os_service_default +# +# [*username*] +# (optional) User for accessing neutron and other services. +# Defaults to $::os_service_default +# +# [*project_name*] +# (optional) Tenant for accessing neutron and other services +# Defaults to $::os_service_default +# +# [*password*] +# (optional) Password for user +# Defaults to $::os_service_default +# +# [*user_domain_name*] +# (optional) keystone user domain +# Defaults to $::os_service_default +# +# [*project_domain_name*] +# (optional) keystone project domain +# Defaults to $::os_service_default +# + +class octavia::service_auth ( + $auth_url = $::os_service_default, + $username = $::os_service_default, + $project_name = $::os_service_default, + $password = $::os_service_default, + $user_domain_name = $::os_service_default, + $project_domain_name = $::os_service_default, +) { + + include ::octavia::deps + + octavia_config { + 'service_auth/auth_url' : value => $auth_url; + 'service_auth/username' : value => $username; + 'service_auth/project_name' : value => $project_name; + 'service_auth/password' : value => $password; + 'service_auth/user_domain_name' : value => $user_domain_name; + 'service_auth/project_domain_name' : value => $project_domain_name; + } +} diff --git a/releasenotes/notes/add-service-auth-configuration-f70310c15b15443c.yaml b/releasenotes/notes/add-service-auth-configuration-f70310c15b15443c.yaml new file mode 100644 index 00000000..13d4faa5 --- /dev/null +++ b/releasenotes/notes/add-service-auth-configuration-f70310c15b15443c.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add support for configuring 'service_auth' section parameters in octavia. diff --git a/spec/classes/octavia_service_auth_spec.rb b/spec/classes/octavia_service_auth_spec.rb new file mode 100644 index 00000000..fdfbe8f5 --- /dev/null +++ b/spec/classes/octavia_service_auth_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe 'octavia::service_auth' do + + shared_examples_for 'service-auth' do + context 'with default params' do + it 'configures default auth' do + is_expected.to contain_octavia_config('service_auth/auth_url').with_value('') + is_expected.to contain_octavia_config('service_auth/username').with_value('') + is_expected.to contain_octavia_config('service_auth/project_name').with_value('') + is_expected.to contain_octavia_config('service_auth/password').with_value('') + is_expected.to contain_octavia_config('service_auth/user_domain_name').with_value('') + is_expected.to contain_octavia_config('service_auth/project_domain_name').with_value('') + end + end + + context 'when credentials are configured' do + let :params do + { :auth_url => 'http://199.199.199.199:64371', + :username => 'some_user', + :project_name => 'some_project_name', + :password => 'secure123', + :user_domain_name => 'my_domain_name', + :project_domain_name => 'our_domain_name' + } + end + + it 'configures credentials' do + is_expected.to contain_octavia_config('service_auth/auth_url').with_value('http://199.199.199.199:64371') + is_expected.to contain_octavia_config('service_auth/username').with_value('some_user') + is_expected.to contain_octavia_config('service_auth/project_name').with_value('some_project_name') + is_expected.to contain_octavia_config('service_auth/password').with_value('secure123') + is_expected.to contain_octavia_config('service_auth/user_domain_name').with_value('my_domain_name') + is_expected.to contain_octavia_config('service_auth/project_domain_name').with_value('our_domain_name') + 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_behaves_like 'service-auth' + end + end +end