Add group to policy management

The move of policy.json into code means the file may not exist. We've
added support to ensure that the file exists in the openstacklib but we
need to make sure the permissions are right for each service. This adds
the group information to the policies so it works right.

Depends-On: I26e8b1384f4f69712da9d06a4c565dfd1f17c9ed
Change-Id: I31bec4b9509e27affd60136537a2a9d6168a62e1
Co-Authored-By: Alex Schultz <aschultz@redhat.com>
This commit is contained in:
Emilien Macchi 2018-01-10 14:08:16 -08:00
parent 78e64fac7e
commit 4c6482c419
3 changed files with 17 additions and 12 deletions

View File

@ -17,6 +17,7 @@ class designate::params {
$zone_manager_service_name = 'designate-zone-manager'
$producer_service_name = 'designate-producer'
$worker_service_name = 'designate-worker'
$group = 'designate'
case $::osfamily {
'RedHat': {

View File

@ -8,18 +8,17 @@
# (optional) Set of policies to configure for designate
# Example :
# {
# 'create_domain' => {
# 'key' => 'create_domain',
# 'value' => 'rule:admin'
# 'designate-context_is_admin' => {
# 'key' => 'context_is_admin',
# 'value' => 'true'
# },
# 'delete_domain' => {
# 'designate-default' => {
# 'key' => 'default',
# 'value' => 'rule:admin'
# 'value' => 'rule:admin_or_owner'
# }
# }
# Defaults to empty hash.
#
#
# [*policy_path*]
# (optional) Path to the designate policy.json file
# Defaults to /etc/designate/policy.json
@ -30,14 +29,18 @@ class designate::policy (
) {
include ::designate::deps
include ::designate::params
validate_hash($policies)
Openstacklib::Policy::Base {
file_path => $policy_path,
file_path => $policy_path,
file_user => 'root',
file_group => $::designate::params::group,
}
create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'designate_config': policy_file => $policy_path }
}

View File

@ -17,8 +17,10 @@ describe 'designate::policy' do
it 'set up the policies' do
is_expected.to contain_openstacklib__policy__base('context_is_admin').with({
:key => 'context_is_admin',
:value => 'foo:bar'
:key => 'context_is_admin',
:value => 'foo:bar',
:file_user => 'root',
:file_group => 'designate',
})
is_expected.to contain_oslo__policy('designate_config').with(
:policy_file => '/etc/designate/policy.json',
@ -27,15 +29,14 @@ describe 'designate::policy' do
end
on_supported_os({
:supported_os => OSDefaults.get_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 'designate policies'
it_configures 'designate policies'
end
end
end