Use yaml instead of json for policy file

Because usage of json for policy file will be deprecated and replaced
by yaml[1].

[1] https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html

Depends-on: https://review.opendev.org/769647
Change-Id: Ibdcf08d14930303941cc5c7276b8af7b7c65e4d4
This commit is contained in:
Takashi Kajinami 2020-12-29 15:54:57 +09:00
parent 58a34d2e93
commit 90a6ed1e54
3 changed files with 18 additions and 12 deletions

View File

@ -20,12 +20,12 @@
# Defaults to empty hash. # Defaults to empty hash.
# #
# [*policy_path*] # [*policy_path*]
# (Optional) Path to the nova policy.json file # (Optional) Path to the nova policy.yaml file
# Defaults to /etc/barbican/policy.json # Defaults to /etc/barbican/policy.yaml
# #
class barbican::policy ( class barbican::policy (
$policies = {}, $policies = {},
$policy_path = '/etc/barbican/policy.json', $policy_path = '/etc/barbican/policy.yaml',
) { ) {
include barbican::deps include barbican::deps
@ -34,9 +34,10 @@ class barbican::policy (
validate_legacy(Hash, 'validate_hash', $policies) validate_legacy(Hash, 'validate_hash', $policies)
Openstacklib::Policy::Base { Openstacklib::Policy::Base {
file_path => $policy_path, file_path => $policy_path,
file_user => 'root', file_user => 'root',
file_group => $::barbican::params::group, file_group => $::barbican::params::group,
file_format => 'yaml',
} }
create_resources('openstacklib::policy::base', $policies) create_resources('openstacklib::policy::base', $policies)

View File

@ -0,0 +1,4 @@
---
upgrade:
- |
Now policy.yaml is used by default instead of policy.json.

View File

@ -5,7 +5,7 @@ describe 'barbican::policy' do
shared_examples_for 'barbican policies' do shared_examples_for 'barbican policies' do
let :params do let :params do
{ {
:policy_path => '/etc/barbican/policy.json', :policy_path => '/etc/barbican/policy.yaml',
:policies => { :policies => {
'context_is_admin' => { 'context_is_admin' => {
'key' => 'context_is_admin', 'key' => 'context_is_admin',
@ -17,13 +17,14 @@ describe 'barbican::policy' do
it 'set up the policies' do it 'set up the policies' do
is_expected.to contain_openstacklib__policy__base('context_is_admin').with({ is_expected.to contain_openstacklib__policy__base('context_is_admin').with({
:key => 'context_is_admin', :key => 'context_is_admin',
:value => 'foo:bar', :value => 'foo:bar',
:file_user => 'root', :file_user => 'root',
:file_group => 'barbican', :file_group => 'barbican',
:file_format => 'yaml',
}) })
is_expected.to contain_oslo__policy('barbican_config').with( is_expected.to contain_oslo__policy('barbican_config').with(
:policy_file => '/etc/barbican/policy.json', :policy_file => '/etc/barbican/policy.yaml',
) )
end end
end end