Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/consul/tasks/consul_policy.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Create a policy with rules
7 consul_policy:
8 name: foo-access
9 rules: |
10 key "foo" {
11 policy = "read"
12 }
13 key "private/foo" {
14 policy = "deny"
15 }
16 register: result
17
18 - assert:
19 that:
20 - result is changed
21 - result.policy.Name == 'foo-access'
22 - result.operation == 'create'
23
24 - name: Update the rules associated to a policy
25 consul_policy:
26 name: foo-access
27 rules: |
28 key "foo" {
29 policy = "read"
30 }
31 key "private/foo" {
32 policy = "deny"
33 }
34 event "bbq" {
35 policy = "write"
36 }
37 register: result
38
39 - assert:
40 that:
41 - result is changed
42 - result.operation == 'update'
43
44 - name: Update reports not changed when updating again without changes
45 consul_policy:
46 name: foo-access
47 rules: |
48 key "foo" {
49 policy = "read"
50 }
51 key "private/foo" {
52 policy = "deny"
53 }
54 event "bbq" {
55 policy = "write"
56 }
57 register: result
58
59 - assert:
60 that:
61 - result is not changed
62 - result.operation is not defined
63
64 - name: Remove a policy
65 consul_policy:
66 name: foo-access
67 state: absent
68 register: result
69 - assert:
70 that:
71 - result is changed
72 - result.operation == 'remove'