diff --git a/manifests/limit.pp b/manifests/limit.pp new file mode 100644 index 0000000..d8bdafb --- /dev/null +++ b/manifests/limit.pp @@ -0,0 +1,81 @@ +# == Define: oslo::limit +# +# Configure oslo_limit options +# +# === Parameters: +# +# [*endpoint_id*] +# (Required) The service's endpoint id which is registered in Keystone. +# +# [*username*] +# (Required) The name of the service user +# +# [*password*] +# (Required) Password to create for the service user +# +# [*auth_url*] +# (Required) The URL to use for authentication. +# +# [*project_name*] +# (Required) Service project name +# +# [*user_domain_name*] +# (Optional) Name of domain for $username +# Defaults to 'Default'. +# +# [*project_domain_name*] +# (Optional) Name of domain for $project_name +# Defaults to 'Default'. +# +# [*auth_type*] +# (Optional) Authentication type to load +# Defaults to 'password'. +# +# [*service_type*] +# (Optional) The name or type of the service as it appears in the service +# catalog. This is used to validate tokens that have restricted access rules. +# Defaults to $::os_service_default. +# +# [*valid_interfaces*] +# (Optional) List of interfaces, in order of preference, for endpoint URL. +# Defaults to $::os_service_default. +# +# [*region_name*] +# (Optional) The region in which the identity server can be found. +# Defaults to $::os_service_default. +# +# [*endpoint_override*] +# (Optional) Always use this endpoint URL for requests for this client. +# Defualts to $::os_service_default. +# +define oslo::limit( + $endpoint_id, + $username, + $password, + $auth_url, + $project_name, + $user_domain_name = 'Default', + $project_domain_name = 'Default', + $auth_type = 'password', + $service_type = $::os_service_default, + $valid_interfaces = $::os_service_default, + $region_name = $::os_service_default, + $endpoint_override = $::os_service_default, +) { + + $limit_options = { + 'oslo_limit/endpoint_id' => { value => $endpoint_id }, + 'oslo_limit/username' => { value => $username }, + 'oslo_limit/password' => { value => $password }, + 'oslo_limit/auth_url' => { value => $auth_url }, + 'oslo_limit/project_name' => { value => $project_name }, + 'oslo_limit/user_domain_name' => { value => $user_domain_name }, + 'oslo_limit/project_domain_name' => { value => $project_domain_name }, + 'oslo_limit/auth_type' => { value => $auth_type }, + 'oslo_limit/service_type' => { value => $service_type }, + 'oslo_limit/valid_interfaces' => { value => join(any2array($valid_interfaces), ',') }, + 'oslo_limit/region_name' => { value => $region_name }, + 'oslo_limit/endpoint_override' => { value => $endpoint_override }, + } + create_resources($name, $limit_options) +} diff --git a/releasenotes/notes/oslo-limit-opts-4ec9fa3880a991f4.yaml b/releasenotes/notes/oslo-limit-opts-4ec9fa3880a991f4.yaml new file mode 100644 index 0000000..4f2eb56 --- /dev/null +++ b/releasenotes/notes/oslo-limit-opts-4ec9fa3880a991f4.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``oslo::limit`` resource type has been added. This manages + parameters of the ``oslo.limit`` library. diff --git a/spec/defines/oslo_limit_spec.rb b/spec/defines/oslo_limit_spec.rb new file mode 100644 index 0000000..163c507 --- /dev/null +++ b/spec/defines/oslo_limit_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper' + +describe 'oslo::limit' do + + let (:title) { 'keystone_config' } + + shared_examples 'oslo::limit' do + + let :required_params do + { + :endpoint_id => '770f924a-e483-4b43-a6f3-73acc91f4757', + :username => 'keystone', + :password => 'keystone_password', + :auth_url => 'http://127.0.0.1:5000/v3', + :project_name => 'services', + } + end + + context 'with default parameters' do + let :params do + required_params + end + + it 'configures the required params' do + is_expected.to contain_keystone_config('oslo_limit/endpoint_id').with_value('770f924a-e483-4b43-a6f3-73acc91f4757') + is_expected.to contain_keystone_config('oslo_limit/username').with_value('keystone') + is_expected.to contain_keystone_config('oslo_limit/password').with_value('keystone_password') + is_expected.to contain_keystone_config('oslo_limit/auth_url').with_value('http://127.0.0.1:5000/v3') + is_expected.to contain_keystone_config('oslo_limit/project_name').with_value('services') + end + + it 'configures the default params' do + is_expected.to contain_keystone_config('oslo_limit/user_domain_name').with_value('Default') + is_expected.to contain_keystone_config('oslo_limit/project_domain_name').with_value('Default') + is_expected.to contain_keystone_config('oslo_limit/auth_type').with_value('password') + is_expected.to contain_keystone_config('oslo_limit/service_type').with_value('') + is_expected.to contain_keystone_config('oslo_limit/valid_interfaces').with_value('') + is_expected.to contain_keystone_config('oslo_limit/region_name').with_value('') + is_expected.to contain_keystone_config('oslo_limit/endpoint_override').with_value('') + end + end + + context 'with parameters overridden' do + let :params do + required_params.merge!({ + :user_domain_name => 'UserDomain', + :project_domain_name => 'ProjectDomain', + :auth_type => 'v3password', + :service_type => 'identity', + :valid_interfaces => ['admin', 'internal'], + :region_name => 'regionOne', + :endpoint_override => 'http://localhost:5000', + }) + end + + it 'configures the overridden values' do + is_expected.to contain_keystone_config('oslo_limit/user_domain_name').with_value('UserDomain') + is_expected.to contain_keystone_config('oslo_limit/project_domain_name').with_value('ProjectDomain') + is_expected.to contain_keystone_config('oslo_limit/auth_type').with_value('v3password') + is_expected.to contain_keystone_config('oslo_limit/service_type').with_value('identity') + is_expected.to contain_keystone_config('oslo_limit/valid_interfaces').with_value('admin,internal') + is_expected.to contain_keystone_config('oslo_limit/region_name').with_value('regionOne') + is_expected.to contain_keystone_config('oslo_limit/endpoint_override').with_value('http://localhost:5000') + 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 + + include_examples 'oslo::limit' + end + end +end