From 18b21aea40647007b8885424defab6d99ed02d17 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 29 Dec 2020 16:01:54 +0900 Subject: [PATCH] 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: Ic94584b92fdd3f1b3dc76a46d93ddff8d725e6db --- manifests/policy.pp | 17 +++++++++-------- ...rmat-from-json-to-yaml-06ba9c13ea4cc8f1.yaml | 4 ++++ spec/classes/glance_policy_spec.rb | 13 +++++++------ 3 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 releasenotes/notes/migrate-policy-format-from-json-to-yaml-06ba9c13ea4cc8f1.yaml diff --git a/manifests/policy.pp b/manifests/policy.pp index f22509f0..a94e52f4 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -20,12 +20,12 @@ # Defaults to empty hash. # # [*policy_path*] -# (Optional) Path to the glance policy.json file -# Defaults to /etc/glance/policy.json +# (Optional) Path to the glance policy.yaml file +# Defaults to /etc/glance/policy.yaml # class glance::policy ( $policies = {}, - $policy_path = '/etc/glance/policy.json', + $policy_path = '/etc/glance/policy.yaml', ) { include glance::deps @@ -34,11 +34,12 @@ class glance::policy ( validate_legacy(Hash, 'validate_hash', $policies) Openstacklib::Policy::Base { - file_path => $policy_path, - file_user => 'root', - file_group => $::glance::params::group, - require => Anchor['glance::config::begin'], - notify => Anchor['glance::config::end'], + file_path => $policy_path, + file_user => 'root', + file_group => $::glance::params::group, + file_format => 'yaml', + require => Anchor['glance::config::begin'], + notify => Anchor['glance::config::end'], } create_resources('openstacklib::policy::base', $policies) diff --git a/releasenotes/notes/migrate-policy-format-from-json-to-yaml-06ba9c13ea4cc8f1.yaml b/releasenotes/notes/migrate-policy-format-from-json-to-yaml-06ba9c13ea4cc8f1.yaml new file mode 100644 index 00000000..fd7e1a85 --- /dev/null +++ b/releasenotes/notes/migrate-policy-format-from-json-to-yaml-06ba9c13ea4cc8f1.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - | + Now policy.yaml is used by default instead of policy.json. diff --git a/spec/classes/glance_policy_spec.rb b/spec/classes/glance_policy_spec.rb index 2a0239d2..5579f4a2 100644 --- a/spec/classes/glance_policy_spec.rb +++ b/spec/classes/glance_policy_spec.rb @@ -5,7 +5,7 @@ describe 'glance::policy' do shared_examples_for 'glance policies' do let :params do { - :policy_path => '/etc/glance/policy.json', + :policy_path => '/etc/glance/policy.yaml', :policies => { 'context_is_admin' => { 'key' => 'context_is_admin', @@ -17,13 +17,14 @@ describe 'glance::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', - :file_user => 'root', - :file_group => 'glance', + :key => 'context_is_admin', + :value => 'foo:bar', + :file_user => 'root', + :file_group => 'glance', + :file_format => 'yaml', }) is_expected.to contain_oslo__policy('glance_api_config').with( - :policy_file => '/etc/glance/policy.json', + :policy_file => '/etc/glance/policy.yaml', ) end end