Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix roles/policies normalization in consul_token. #9845

Merged
merged 2 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/9845-consul_token_idempotency.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- 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).
2 changes: 1 addition & 1 deletion plugins/modules/consul_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def normalize_link_obj(api_obj, module_obj, key):

for obj in module_objs:
identifier = obj.get("ID")
name = obj.get("Name)")
name = obj.get("Name")
if identifier and not name and identifier in id_to_name:
obj["Name"] = id_to_name[identifier]
if not identifier and name and name in name_to_id:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/consul/tasks/consul_token.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
state: present
accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21
policies:
- id: "{{ create_result.token.Policies[-1].ID }}"
- name: foo-access2
register: result

- assert:
Expand Down