-
Notifications
You must be signed in to change notification settings - Fork 157
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 of hashivault_write #394
Comments
Similar to update, but as I recall update only changes values that are present in the request https://github.com/TerryHowe/ansible-modules-hashivault/blob/main/ansible/modules/hashivault/hashivault_write.py#L122 |
I apologize but I didn't try from start as documentation says Note some possible issue here (evaluate if they seem useful to you):
fatal: [localhost]: FAILED! => changed=false msg: 'argument ''update'' is of type and we were unable to convert to bool: The value '''' is not a valid boolean. Valid booleans include: 0, ********, ''0'', ''false'', ''f'', ''yes'', ''t'', ''off'', ''n'', ''no'', ''on'', ''y'', ''true'', ''********'''
workaround Idempotency can be also reached externally to the module using code like this: - name: kv_cfg | Get hashicorp vault kv (read/get) hashivault_read: token: "..." url: "..." key: "..." mount_point: "..." secret: "..." secret_version: "..." version: "..." register: item_current changed_when: false failed_when: false failed_when: > item_current.rc != 0 and not item_current.msg is regex("Secret.*is not in vault") - name: kv_cfg | Set hashicorp vault kv (write/post) hashivault_write: token: "..." url: "..." mount_point: "..." secret: "..." version: "..." cas: "..." alternate_data: "..." data: "..." when: > ( item_current.rc != 0 and item_current.msg is regex("Secret.*is not in vault") ) or item_current.value|to_json != item_kv.value.data|to_json Many ways to go... even if the main way is always the module own idempotency. As soon I'll end this project for which the time is about to end, I'll try to see insiede the modules code, if I find some time slots and. |
For issue part (1.) as workaround casting to bool seems to work: update: {{(myupdate|default(omit))|bool}} |
Should not module
hashivault_write
check if data to write is changed (desired_state
!=current_state
) ?For Example: for a kv put action probably it should possible to write only if data is changed instead of put on every run increasing version for the same data.
I'll try to use
hashivault_read
to compare data but I think integrated check inside write module better respects the idempotency paradigm.The text was updated successfully, but these errors were encountered: