diff --git a/manifests/api.pp b/manifests/api.pp index 946ed732..2cfe45c8 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -22,6 +22,10 @@ # (optional) ensure state for package. # Defaults to 'present' # +# [*auth_strategy*] +# (optional) set authentication mechanism +# Defaults to 'keystone' +# # [*sync_db*] # (optional) Run octavia-db-manage upgrade head on api nodes after installing the package. # Defaults to false @@ -32,6 +36,7 @@ class octavia::api ( $package_ensure = 'present', $host = '0.0.0.0', $port = '9876', + $auth_strategy = 'keystone', $sync_db = false, ) inherits octavia::params { @@ -39,6 +44,10 @@ class octavia::api ( include ::octavia::policy include ::octavia::db + if $auth_strategy == 'keystone' { + include ::octavia::keystone::authtoken + } + package { 'octavia-api': ensure => $package_ensure, name => $::octavia::params::api_package_name, @@ -69,6 +78,7 @@ class octavia::api ( octavia_config { 'DEFAULT/host' : value => $host; 'DEFAULT/port' : value => $port; + 'DEFAULT/auth_strategy' : value => $auth_strategy; } } diff --git a/releasenotes/notes/add-auth-strategy-99518a6623bcb665.yaml b/releasenotes/notes/add-auth-strategy-99518a6623bcb665.yaml new file mode 100644 index 00000000..049eb82c --- /dev/null +++ b/releasenotes/notes/add-auth-strategy-99518a6623bcb665.yaml @@ -0,0 +1,4 @@ +--- +features: + - support for configuring auth_strategy for the Octavia api service has + been added and the keystone authtoken support properly initialized. diff --git a/spec/classes/octavia_api_spec.rb b/spec/classes/octavia_api_spec.rb index 3fe05faf..8f502c8c 100644 --- a/spec/classes/octavia_api_spec.rb +++ b/spec/classes/octavia_api_spec.rb @@ -4,7 +4,11 @@ describe 'octavia::api' do let :pre_condition do "class { 'octavia': } - include ::octavia::db" + include ::octavia::db + class { '::octavia::keystone::authtoken': + password => 'password'; + } + " end let :params do @@ -21,6 +25,7 @@ describe 'octavia::api' do it { is_expected.to contain_class('octavia::deps') } it { is_expected.to contain_class('octavia::params') } it { is_expected.to contain_class('octavia::policy') } + it { is_expected.to contain_class('octavia::keystone::authtoken') } it 'installs octavia-api package' do is_expected.to contain_package('octavia-api').with( @@ -30,6 +35,20 @@ describe 'octavia::api' do ) end + context 'when not parameters are defined' do + before do + params.clear() + end + it 'configures with default values' do + is_expected.to contain_octavia_config('DEFAULT/host').with_value( '0.0.0.0' ) + is_expected.to contain_octavia_config('DEFAULT/port').with_value( '9876' ) + is_expected.to contain_octavia_config('DEFAULT/auth_strategy').with_value( 'keystone' ) + end + it 'does not sync the database' do + is_expected.not_to contain_class('octavia::db::sync') + end + end + it 'configures bind_host and bind_port' do is_expected.to contain_octavia_config('DEFAULT/host').with_value( params[:host] ) is_expected.to contain_octavia_config('DEFAULT/port').with_value( params[:port] )