-
Notifications
You must be signed in to change notification settings - Fork 336
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
azure_rm_roleassignment fails with 'Error creating role assignment: (RoleAssignmentExists)' #1137
Comments
@paultaiton as requested, please see output of ###
|
I apologize for the delay, I haven't had a chance to look at this yet. |
@paultaiton There is no problem for me to create and re-create role assignments locally. Could you please share your playbook and log details? This will help solve the current problem, and if possible, you can try to reinstall a new environment, thank you!
|
@Fred-sun in your test, did the second run come back as changed = false ? I'm assuming yes, but want to confirm. |
hi @Fred-sun , here is the full
the relevant output as shared earlier is as follows, please let me know if you were asking for something else:
I've run this on a new EE since the first time the issue occurred (and upgraded the collection version from I noticed you've used |
@paultaiton Yes, idempotent! Thanks! |
@Mohammad-Atif-Khan The use of scope is as follows:
|
@Fred-sun thanks, but that is exactly how I've been using it. I just tested it again without Execution Environment and I still get the same error. I even tried bypassing ansible-navigator and using ansible-playbook to run it but still the same. It seems like the I cannot get debug print statements to work (sorry I've not developed a module yet) - can you advise how I could get some messages out to stdout? I'm trying to debug the module myself but I cannot get any messages out to view during the execution. I've tried the vanilla |
@Mohammad-Atif-Khan Repeated tests have not met your problem. Can you try it in a different environment? Also, makesure that the version installed is v1.15.0(latest version). Thanks! |
I have also tried replicating the reported issue without success. |
@paultaiton Can I have a look at your full script? Thanks! |
I did try it in a new environment (v1.15.0) and got the same error. I'm using a workaround, where I run the info module and check if the role assignment exists first and then conditionally run the role assignment thereafter. |
@Mohammad-Atif-Khan If the roleassignment you created does not exist, can you successfully create it? Thanks! |
@Fred-sun , yes, correct. If did not exist it creates it correctly; however if it does exist, it returns an error. |
@Mohammad-Atif-Khan Are you still using the script in comments? Thanks! |
It's pretty basic, I do everything via parameters for testing. I cannot get it to fail on creating a role assignment that already exists. |
hi @Fred-sun , I only modified it to use the workaround I mentioned before. Here is the relevant YAML:
Something very strange I noticed: I retried the original playbook (without workaround), but on a different subscription, and it worked! It did not fail for an existing assignment. Any idea what could explain that behavior? |
@Mohammad-Atif-Khan I have also noticed this problem and I am dealing with it. Thank you! |
@Mohammad-Atif-Khan The creation fails because a role has been created for the resource group in the specified id. When you create a role, a message is displayed indicating a failure. You can try it by specifying a new ID (different resource group). Thanks! |
I'm not sure I follow. Is the problem with the role as opposed to a role assignment? |
@Mohammad-Atif-Khan Is your problem still there? As mentioned earlier, information about a role that should be assigned to you is used with its role, resulting in a failure to assign --- (RoleAssignmentExists)Thanks ! |
@Mohammad-Atif-Khan If you have no further questions, I will close it in a week. Thank you! |
Hi Fred,
I'm sorry I don't follow your meaning. Can you please elaborate? What's causing this issue?
…________________________________
From: Fred-sun ***@***.***>
Sent: Friday, March 29, 2024 3:59 a.m.
To: ansible-collections/azure
Cc: Khan, Atif; Mention
Subject: Re: [ansible-collections/azure] azure_rm_roleassignment fails with 'Error creating role assignment: (RoleAssignmentExists)' (Issue #1137)
@Mohammad-Atif-Khan<https://github.com/Mohammad-Atif-Khan> Is your problem still there? As mentioned earlier, information about a role that should be assigned to you is used with its role, resulting in a failure to assign --- (RoleAssignmentExists)Thanks !
—
Reply to this email directly, view it on GitHub<#1137 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A335N7G3PWWQCE36P66W7Q3Y2U3P7AVCNFSM6AAAAAAWR5GSGSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGAYDKMRWHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
________________________________
NOTICE: This communication and any attachments ("this message") may contain information which is privileged, confidential, proprietary or otherwise subject to restricted disclosure under applicable law. This message is for the sole use of the intended recipient(s). Any unauthorized use, disclosure, viewing, copying, alteration, dissemination or distribution of, or reliance on, this message is strictly prohibited. If you have received this message in error, or you are not an authorized or intended recipient, please notify the sender immediately by replying to this message, delete this message and all copies from your e-mail system and destroy any printed copies. You are receiving this communication because you are listed as a current WSP contact. Should you have any questions regarding WSP's electronic communications policy, please consult our Anti-Spam Commitment at www.wsp.com/casl<http://www.wsp.com/casl>. For any concern or if you believe you should not be receiving this message, please forward this message to ***@***.******@***.***> so that we can promptly address your request. Note that not all messages sent by WSP qualify as commercial electronic messages.
AVIS : Ce message, incluant tout fichier l'accompagnant (< le message >), peut contenir des renseignements ou de l'information privilegies, confidentiels, proprietaires ou a divulgation restreinte en vertu de la loi. Ce message est destine a l'usage exclusif du/des destinataire(s) voulu(s). Toute utilisation non permise, divulgation, lecture, reproduction, modification, diffusion ou distribution est interdite. Si vous avez recu ce message par erreur, ou que vous n'etes pas un destinataire autorise ou voulu, veuillez en aviser l'expediteur immediatement et detruire le message et toute copie electronique ou imprimee. Vous recevez cette communication car vous faites partie des contacts de WSP. Si vous avez des questions concernant la politique de communications electroniques de WSP, veuillez consulter notre Engagement anti-pourriel au www.wsp.com/lcap<http://www.wsp.com/lcap>. Pour toute question ou si vous croyez que vous ne devriez pas recevoir ce message, priere de le transferer au ***@***.******@***.***> afin que nous puissions rapidement traiter votre demande. Notez que ce ne sont pas tous les messages transmis par WSP qui constituent des messages electroniques commerciaux.
-LAEmHhHzdJzBlTWfa4Hgs7pbKl
|
Hi, i am having the exact same issue, its like the module is not idempotent: Using the following: Collection version 2.4.0 Ansible version:
If the role assignment does not exists, it gets created:
Next time it errors out:
|
It's been quite a while since I've worked on any azure ansible code, so I'm a bit rusty. |
Hi @Fred-sun , can we please fix this? I don't think it is a big ask at all since other modules support idempotency. It is quite disappointing to find such bugs in a collection that Microsoft maintains and which is also advertised as certified collection under the commercial offering of AWX in RHAAP. |
@Mohammad-Atif-Khan I am very sorry for replying to your question so late. But for the error you mentioned, I also only see if the scope definition does not ‘/‘ start causing this error(subscriptions/xxx/resourceGroups/v-xisuRG03 ---- /subscriptions/xxxx/resourceGroups/v-xisuRG03). In order to better solve this problem, can you provide the full playbook ad print the execution information of ansible-playbook tasks.yml -*** -vvvv during execution? Thank you! |
Hi @Fred-sun, I added another / to share the output for below which made it // and it still throws the same error. In any case, the module works when the role assignment does not exist and it clearly is made to exit with error code when it does, so it has to be a bug or a miss in the idempotency implementation for this module, right?
|
@Mohammad-Atif-Khan The '{{target_resource_info.id}}' start is already '/' please do not add '/', please try again, thank you!
|
@Mohammad-Atif-Khan Why add '/'? Please delete and try again. Thank you!
|
Hi @Fred-sun , Another very interesting observation: I could not reproduce this error on a different target tenant! |
@Mohammad-Atif-Khan Is it possible that your current account has a special setting that prevents you from accessing the assigned user information? |
This module clearly has issues. I see the above closed without resolution and I'm also encountering this issue. I'm not sure what I'm missing here. It creates the RoleAssignment and then fails on subsequent runs. /home/vscode/.ansible/collections/ansible_collectionsCollection Version azure.azcollection 3.1.0 TASK [Configure SPN as Keyvault Contributor] ********************************************************************************************************* `
|
@BenTheCloudGuy Because I did not encounter this problem in the local test, and repeated simulation many times. Could you please describe this problem and detailed logs in detail, so as to analyze this problem? Thank you! |
@BenTheCloudGuy Already fixed in #1807, The scope in the return value does not end with /, so the / in the configuration value is deleted when comparing. |
SUMMARY
When trying to use the
azure_rm_roleassignment
module and the requested assignment exists, the task fails reporting the same:instead of continuing with a 'success' since the module should be idempotent.
ISSUE TYPE
COMPONENT NAME
azure_rm_roleassignment
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
I'm using ansible-navigator with an Execution Environment on docker CE. The above outputs are from inside the EE container.
The collection version is
v1.15.0
as confirmed by looking at changelog:This is the build file for anisble-builder if that is of interest:
STEPS TO REPRODUCE
where
role_definition
is the output of theazure_rm_roledefinition_info
module, containing fully qualified definition ID.EXPECTED RESULTS
The module should simply continue with status 'Ok' (ie unchanged) and not fail as it does currently
ACTUAL RESULTS
The task fails with
Code: RoleAssignmentExists
The text was updated successfully, but these errors were encountered: