diff --git a/manifests/policy.pp b/manifests/policy.pp index b868d63b..116a7814 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -4,6 +4,10 @@ # # === Parameters # +# [*enforce_scope*] +# (Optional) Whether or not to enforce scope when evaluating policies. +# Defaults to $::os_service_default. +# # [*policies*] # (Optional) Set of policies to configure for ironic # Example : @@ -24,8 +28,9 @@ # Defaults to /etc/ironic/policy.yaml # class ironic::policy ( - $policies = {}, - $policy_path = '/etc/ironic/policy.yaml', + $enforce_scope = $::os_service_default, + $policies = {}, + $policy_path = '/etc/ironic/policy.yaml', ) { include ironic::deps @@ -42,6 +47,9 @@ class ironic::policy ( create_resources('openstacklib::policy::base', $policies) - oslo::policy { 'ironic_config': policy_file => $policy_path } + oslo::policy { 'ironic_config': + enforce_scope => $enforce_scope, + policy_file => $policy_path + } } diff --git a/releasenotes/notes/oslo_policy-enforce_scope-ec5b75a0fd442120.yaml b/releasenotes/notes/oslo_policy-enforce_scope-ec5b75a0fd442120.yaml new file mode 100644 index 00000000..17ad9430 --- /dev/null +++ b/releasenotes/notes/oslo_policy-enforce_scope-ec5b75a0fd442120.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``ironic::policy::enforce_scope`` parameter has been added to + support the corresponding parameter in oslo.policy library. diff --git a/spec/classes/ironic_policy_spec.rb b/spec/classes/ironic_policy_spec.rb index 76970a2d..70741a5d 100644 --- a/spec/classes/ironic_policy_spec.rb +++ b/spec/classes/ironic_policy_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' describe 'ironic::policy' do - - shared_examples_for 'ironic policies' do + shared_examples 'ironic::policy' do let :params do { - :policy_path => '/etc/ironic/policy.yaml', - :policies => { + :enforce_scope => false, + :policy_path => '/etc/ironic/policy.yaml', + :policies => { 'context_is_admin' => { 'key' => 'context_is_admin', 'value' => 'foo:bar' @@ -24,20 +24,21 @@ describe 'ironic::policy' do :file_format => 'yaml', }) is_expected.to contain_oslo__policy('ironic_config').with( - :policy_file => '/etc/ironic/policy.yaml', + :enforce_scope => false, + :policy_file => '/etc/ironic/policy.yaml', ) end 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_configures 'ironic policies' + it_behaves_like 'ironic::policy' end end end