]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/openstacklib/manifests/policy/base.pp
try with modules from master
[dsa-puppet.git] / 3rdparty / modules / openstacklib / manifests / policy / base.pp
1 # == Definition: openstacklib::policy::base
2 #
3 # This resource configures the policy.json file for an OpenStack service
4 #
5 # == Parameters:
6 #
7 #  [*file_path*]
8 #    Path to the policy.json file
9 #    string; required
10 #
11 #  [*key*]
12 #    The key to replace the value for
13 #    string; required; the key to replace the value for
14 #
15 #  [*value*]
16 #    The value to set
17 #    string; optional; the value to set
18 #
19 define openstacklib::policy::base (
20   $file_path,
21   $key,
22   $value = '',
23 ) {
24
25   # Add entry if it doesn't exists
26   augeas { "${file_path}-${key}-${value}-add":
27     lens    => 'Json.lns',
28     incl    => $file_path,
29     changes => [
30       "set dict/entry[last()+1] \"${key}\"",
31       "set dict/entry[last()]/string \"${value}\"",
32     ],
33     onlyif  => "match dict/entry[*][.=\"${key}\"] size == 0",
34   }
35
36   # Requires that the entry is added before this call or it will fail.
37   augeas { "${file_path}-${key}-${value}" :
38     lens    => 'Json.lns',
39     incl    => $file_path,
40     changes => "set dict/entry[*][.=\"${key}\"]/string \"${value}\"",
41     require => Augeas["${file_path}-${key}-${value}-add"],
42   }
43
44 }
45