Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Make secrethub_write idempotent #2

Open
SimonBarendse opened this issue Oct 13, 2018 · 4 comments
Open

Make secrethub_write idempotent #2

SimonBarendse opened this issue Oct 13, 2018 · 4 comments

Comments

@SimonBarendse
Copy link
Member

Change request

Current behavior

When running a playbook with a secrethub_write several times,
each time a new version of the secret is written.

Expected behavior

When running a playbook with a secrethub_write several times,
only the first time a new version of the secret is written.

Proposal

Before writing the secret, the secret should be read. When the current
value is the same as the target value, the write is not performed.

The module will reflect in its return whether it has changed the secret
value.

@SimonBarendse
Copy link
Member Author

I propose to add a state parameter, that can have the present or new value. When the state is new, a new version will always be written, even if the value would not change. The present state will be default and will only write when that would change the value of the latest version of the secret.
This is useful when you read specific secret versions from the playbook.

@SimonBarendse
Copy link
Member Author

the s3 module has a similar parameter. They call it overwrite with options: always, different and never.

@mackenbach
Copy link
Member

Ah, that's a neat trick. What about force_new: [always/true, different, never/false] with default value false?

@SimonBarendse
Copy link
Member Author

I would pick different as default, as the module will then be idempotent by default.

I think never/false is only useful when the execution of the module is conditional, but is not the desired behavior in a default use-case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants