-
Notifications
You must be signed in to change notification settings - Fork 156
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
Idempotency issue for hashivault_approle_role #391
Comments
Should be going through https://github.com/TerryHowe/ansible-modules-hashivault/blob/main/ansible/modules/hashivault/hashivault_approle_role.py#L182 I would suspect https://github.com/TerryHowe/ansible-modules-hashivault/blob/main/ansible/modules/hashivault/hashivault_approle_role.py#L169 I see that token_policies defaults to [] and maybe that is transformed to None. Need a higher logging level maybe to see more. |
Not sure why a value should be None in that code snippet; if role_file: try: desired_state = json.loads(open(params.get('role_file'), 'r').read()) except Exception as e: return {'changed': False, 'failed': True, 'msg': 'Error opening role file <%s>: %s' % (params.get('role_file'), str(e))} else: for arg in args: value = params.get(arg) if value is not None: desired_state[arg] = value if arg are present ( |
Hi @TerryHowe, What tools you are using for hashivault devel/debug ? This can speed up my python/ansible devel exeperience so if I'll can catch issues I'll can help the community Is pdb an option ? |
I have identified a few different issues that appear to be able to cause this and wanted to get some feedback on methods of fixing them:
If the proposed fixes above sound good I can test them and open a PR to merge. cc. @TerryHowe @Roxyrob |
For 2 above, hashicorp/vault#11961 appears to be the hashicorp-vault upstream issue. They don't appear to have any timeline for leads for a fix so a documentation note is likely our best path here. |
I use a combination of PyCharm and vi depending on what I'm doing and rarely use a debugger, especially for this project. Normally a stack trace, a couple debug prints or returning data in the results is more than enough. Sorry about the super slow response, totally missed this question. |
I think there are some other modules that compare times and have unit problems like that. There may be a precedent set somewhere else or maybe just always convert to seconds before comparison. |
I did some digging on the Vault side and it appears to use time.ParseDuration (https://cs.opensource.google/go/go/+/refs/tags/go1.20.5:src/time/format.go;l=1589) to handle parsing the friendly values. Based on the complexity of that function and the precedent I've found in other parts of the code for TTL to always be integer seconds, I think that is the approach I will write up in my PR. |
Take all TTL arguments to hashivault_approle_role in seconds as this is the unit that Vault/HVAC will return.
Hi,
also 'hashivault_approle_role' isn't idempotent.
Base playbook code that works:
You can run above playbook with correct idempotency but, as in below code, any argument passed different by module/api defaults value (also simple
state: absent
) make the module not idempotent anymore:same issue with any other arguments:
The text was updated successfully, but these errors were encountered: