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

Fixed mismatch assignment error #613

Conversation

Spacebjorn
Copy link
Contributor

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

azure_rm_roleassignment.py

ADDITIONAL INFORMATION

Errpr code: "msg": "State Mismatch Error: The assignment name exists, but does not match the provided role"

Changing the fatal message to print the elif comparison statement will show:
Error code: "msg": "role_assignment.get(): b7e6dc6d-f1e8-4753-8033-0f276bb0955b self.role_definition_id: b"

After my suggested change the code will actually do a proper comparison ending up with:
"msg": "role_assignment.get(): b7e6dc6d-f1e8-4753-8033-0f276bb0955b self.role_definition_id: b7e6dc6d-f1e8-4753-8033-0f276bb0955b"

Trying to rerun the code below will result in the error saying there's a mismatch between the roles even though a azure.azcollection.azure_rm_roleassignment_info task to the role will show they're the exact same.

    azure.azcollection.azure_rm_roleassignment:
      name: "{{ (ansible_azure_subscription_id + '/' + managed_identity_id + '/b7e6dc6d-f1e8-4753-8033-0f276bb0955b') | to_uuid }}"
      scope:
        "/subscriptions/{{ ansible_azure_subscription_id }}\
        /resourceGroups/{{ resource_group_name }}\
        /providers/Microsoft.Storage/storageAccounts/{{ storage_account_name }}"
      assignee_object_id: "{{ managed_identity_id }}"
      role_definition_id:
        "/subscriptions/{{ ansible_azure_subscription_id }}\
        /providers/Microsoft.Authorization/roleDefinitions/b7e6dc6d-f1e8-4753-8033-0f276bb0955b"
      state: present

@Fred-sun Fred-sun added medium_priority Medium priority work in In trying to solve, or in working with contributors labels Aug 25, 2021
@Fred-sun
Copy link
Collaborator

@Spacebjorn Line306 should not be consistent with the change here! Thank you very much!

if role_assignment and self.role_definition_id and (role_assignment.get('role_definition_id').split('/')[-1].lower()

@Spacebjorn
Copy link
Contributor Author

@Fred-sun Should be fixed for both lines now. Good catch

@Fred-sun Fred-sun added ready_for_review The PR has been modified and can be reviewed and merged and removed work in In trying to solve, or in working with contributors labels Aug 26, 2021
@paultaiton
Copy link
Contributor

@Spacebjorn
Nice fix. I think I developed the faulty bit before I fully understood how to run the integration tests, because how they're written it should have caught this bug.

@Spacebjorn
Copy link
Contributor Author

@paultaiton I would've thought the integration tests would run as prereq before merging as well?

@Spacebjorn
Copy link
Contributor Author

@Fred-sun Not to be rude, but is there any status on this PR? It doesn't change that much and the task is still broken if you rerun it

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Feb 7, 2022

@Spacebjorn LGTM

@xuzhang3 xuzhang3 merged commit e886409 into ansible-collections:dev Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium_priority Medium priority ready_for_review The PR has been modified and can be reviewed and merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants