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: I748ed0cba392d783e75b2cf16833a687d6152a22
Co-Authored-By: Alex Schultz <aschultz@redhat.com>
This commit is contained in:
Emilien Macchi 2018-01-10 14:09:01 -08:00
parent 608fa12a50
commit fd952e2a84
3 changed files with 27 additions and 19 deletions

View File

@ -5,7 +5,8 @@
class heat::params {
include ::openstacklib::defaults
$client_package_name = 'python-heatclient'
$client_package_name = 'python-heatclient'
$group = 'heat'
case $::osfamily {
'RedHat': {

View File

@ -2,21 +2,26 @@
#
# Configure the heat policies
#
# == Parameters
# === Parameters
#
# [*policies*]
# (optional) Set of policies to configure for heat.
# (optional) Set of policies to configure for heat
# Example :
# {
# 'heat-context_is_admin' => {
# 'key' => 'context_is_admin',
# 'value' => 'true'
# },
# 'heat-default' => {
# 'key' => 'default',
# 'value' => 'rule:admin_or_owner'
# }
# }
# Defaults to empty hash.
#
# Example:
# {
# 'heat-context_is_admin' => {'context_is_admin' => 'true'},
# 'heat-default' => {'default' => 'rule:admin_or_owner'}
# }
#
# [*policy_path*]
# (optional) Path to the heat policy.json file.
# Defaults to '/etc/heat/policy.json'.
# (optional) Path to the heat policy.json file
# Defaults to /etc/heat/policy.json
#
class heat::policy (
$policies = {},
@ -24,17 +29,18 @@ class heat::policy (
) {
include ::heat::deps
include ::heat::params
validate_hash($policies)
Openstacklib::Policy::Base {
file_path => $policy_path,
file_path => $policy_path,
file_user => 'root',
file_group => $::heat::params::group,
}
create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'heat_config': policy_file => $policy_path }
Anchor<| title == 'heat::config::start' |>
-> Class['heat::policy']
~> Anchor<| title == 'heat::config::end' |>
}

View File

@ -17,8 +17,10 @@ describe 'heat::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 => 'heat',
})
is_expected.to contain_oslo__policy('heat_config').with(
:policy_file => '/etc/heat/policy.json',
@ -34,8 +36,7 @@ describe 'heat::policy' do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'heat policies'
it_configures 'heat policies'
end
end
end