Skip to content

Commit c12dd2f

Browse files
[PR #9845/7d5357d7 backport][stable-10] Fix roles/policies normalization in consul_token. (#9863)
Fix roles/policies normalization in consul_token. (#9845) * Fix roles/policies normalization in consul_token. * Update changelogs/fragments/9845-consul_token_idempotency.yml Co-authored-by: Felix Fontein <[email protected]> --------- Co-authored-by: Felix Fontein <[email protected]> (cherry picked from commit 7d5357d) Co-authored-by: Florian Apolloner <[email protected]>
1 parent 8253fb1 commit c12dd2f

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- consul_token - fix idempotency when ``policies`` or ``roles`` are supplied by name (https://github.com/ansible-collections/community.general/issues/9841, https://github.com/ansible-collections/community.general/pull/9845).

plugins/modules/consul_token.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def normalize_link_obj(api_obj, module_obj, key):
220220

221221
for obj in module_objs:
222222
identifier = obj.get("ID")
223-
name = obj.get("Name)")
223+
name = obj.get("Name")
224224
if identifier and not name and identifier in id_to_name:
225225
obj["Name"] = id_to_name[identifier]
226226
if not identifier and name and name in name_to_id:

tests/integration/targets/consul/tasks/consul_token.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
state: present
6868
accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21
6969
policies:
70-
- id: "{{ create_result.token.Policies[-1].ID }}"
70+
- name: foo-access2
7171
register: result
7272

7373
- assert:

0 commit comments

Comments
 (0)