X-Git-Url: https://git.donarmstrong.com/?p=dsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fopenstacklib%2Fmanifests%2Fpolicy%2Fbase.pp;fp=3rdparty%2Fmodules%2Fopenstacklib%2Fmanifests%2Fpolicy%2Fbase.pp;h=01919fe650e27d1c279411339f3de16d5fca2d77;hp=0000000000000000000000000000000000000000;hb=8132e6bb1199463f5e334326659c974d4772b3e3;hpb=169cb77932b427c80d2731ca5938ecd617a5ad57 diff --git a/3rdparty/modules/openstacklib/manifests/policy/base.pp b/3rdparty/modules/openstacklib/manifests/policy/base.pp new file mode 100644 index 00000000..01919fe6 --- /dev/null +++ b/3rdparty/modules/openstacklib/manifests/policy/base.pp @@ -0,0 +1,45 @@ +# == Definition: openstacklib::policy::base +# +# This resource configures the policy.json file for an OpenStack service +# +# == Parameters: +# +# [*file_path*] +# Path to the policy.json file +# string; required +# +# [*key*] +# The key to replace the value for +# string; required; the key to replace the value for +# +# [*value*] +# The value to set +# string; optional; the value to set +# +define openstacklib::policy::base ( + $file_path, + $key, + $value = '', +) { + + # Add entry if it doesn't exists + augeas { "${file_path}-${key}-${value}-add": + lens => 'Json.lns', + incl => $file_path, + changes => [ + "set dict/entry[last()+1] \"${key}\"", + "set dict/entry[last()]/string \"${value}\"" + ], + onlyif => "match dict/entry[*][.=\"${key}\"] size == 0" + } + + # Requires that the entry is added before this call or it will fail. + augeas { "${file_path}-${key}-${value}" : + lens => 'Json.lns', + incl => $file_path, + changes => "set dict/entry[*][.=\"${key}\"]/string ${value}", + require => Augeas["${file_path}-${key}-${value}-add"] + } + +} +