Add policy.json management

This is mostly a copy of the existing neutron policy.json management and
leverages the resources in openstacklib for managing designate's
policy.json

Change-Id: I1fbf35b3dfa2e3a9b5f3ec351f8776951dfb41cf
This commit is contained in:
Clayton O'Neill 2015-03-22 14:54:17 +00:00
parent 53d52c929a
commit 2910f825ef
2 changed files with 81 additions and 0 deletions

40
manifests/policy.pp Normal file
View File

@ -0,0 +1,40 @@
# == Class: designate::policy
#
# Configure the designate policies
#
# === Parameters
#
# [*policies*]
# (optional) Set of policies to configure for designate
# Example :
# {
# 'create_domain' => {
# 'key' => 'create_domain',
# 'value' => 'rule:admin'
# },
# 'delete_domain' => {
# 'key' => 'default',
# 'value' => 'rule:admin'
# }
# }
# Defaults to empty hash.
#
#
# [*policy_path*]
# (optional) Path to the designate policy.json file
# Defaults to /etc/designate/policy.json
#
class designate::policy (
$policies = {},
$policy_path = '/etc/designate/policy.json',
) {
validate_hash($policies)
Openstacklib::Policy::Base {
file_path => $policy_path,
}
create_resources('openstacklib::policy::base', $policies)
}

View File

@ -0,0 +1,41 @@
require 'spec_helper'
describe 'designate::policy' do
shared_examples_for 'designate policies' do
let :params do
{
:policy_path => '/etc/designate/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'
})
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'designate policies'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'designate policies'
end
end