Merge "New class nova::metadata::novajoin::policy"
This commit is contained in:
commit
aac76ab197
|
@ -128,6 +128,7 @@ class nova::metadata::novajoin::api (
|
|||
$ipa_realm = undef,
|
||||
) {
|
||||
include ::nova::metadata::novajoin::authtoken
|
||||
include ::nova::metadata::novajoin::policy
|
||||
|
||||
if ! $service_user {
|
||||
fail('service_user is missing')
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# == Class: nova::metadata::novajoin::policy
|
||||
#
|
||||
# Configure the nova policies
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*policies*]
|
||||
# (Optional) Set of policies to configure for novajoin
|
||||
# Example :
|
||||
# {
|
||||
# 'novajoin-compute_service_user' => {
|
||||
# 'key' => 'compute_service_user',
|
||||
# 'value' => 'role:admin'
|
||||
# }
|
||||
# }
|
||||
# Defaults to empty hash.
|
||||
#
|
||||
# [*policy_path*]
|
||||
# (Optional) Path to the novajoin policy.json file
|
||||
# Defaults to /etc/novajoin/policy.json
|
||||
#
|
||||
class nova::metadata::novajoin::policy (
|
||||
$policies = {},
|
||||
$policy_path = '/etc/novajoin/policy.json',
|
||||
) {
|
||||
|
||||
validate_legacy(Hash, 'validate_hash', $policies)
|
||||
|
||||
$policy_defaults = {
|
||||
file_path => $policy_path,
|
||||
file_user => 'root',
|
||||
}
|
||||
|
||||
create_resources('openstacklib::policy::base', $policies, $policy_defaults)
|
||||
|
||||
oslo::policy { 'novajoin_config': policy_file => $policy_path }
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
New class nova::metadata::novajoin::policy allows novajoin policy overrides
|
||||
to be written to /etc/novajoin/policy.json.
|
|
@ -0,0 +1,42 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'nova::metadata::novajoin::policy' do
|
||||
|
||||
shared_examples_for 'novajoin policies' do
|
||||
let :params do
|
||||
{
|
||||
:policy_path => '/etc/novajoin/policy.json',
|
||||
:policies => {
|
||||
'context_is_admin' => {
|
||||
'key' => 'context_is_admin',
|
||||
'value' => 'foo:bar'
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it 'set up the policies' do
|
||||
is_expected.to contain_openstacklib__policy__base('context_is_admin').with({
|
||||
:key => 'context_is_admin',
|
||||
:value => 'foo:bar',
|
||||
:file_user => 'root',
|
||||
})
|
||||
is_expected.to contain_oslo__policy('novajoin_config').with(
|
||||
:policy_file => '/etc/novajoin/policy.json',
|
||||
)
|
||||
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 'novajoin policies'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue