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

vault: add support for delete_continue. #778

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README-vault.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Variable | Description | Required
`data` \|`vault_data` \| `ipavaultdata` | Data to be stored in the vault. | no
`in` \| `datafile_in` | Path to file with data to be stored in the vault. | no
`out` \| `datafile_out` | Path to file to store data retrieved from the vault. | no
`delete_continue` \| `continue` | Continuous mode: don't stop on errors. Valid only if `state` is `absent`. Default: `yes` (bool) | no
`action` | Work on vault or member level. It can be on of `member` or `vault` and defaults to `vault`. | no
`state` | The state to ensure. It can be one of `present`, `absent` or `retrieved`, default: `present`. | no

Expand Down
6 changes: 6 additions & 0 deletions plugins/modules/ipavault.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
description: Manage vaults and secret vaults. KRA service must be enabled.
extends_documentation_fragment:
- ipamodule_base_docs
- ipamodule_base_docs.delete_continue
options:
name:
description: The vault name
Expand Down Expand Up @@ -652,6 +653,7 @@ def main():
['new_password', 'new_password_file'],
['vault_password', 'vault_password_file'],
['vault_public_key', 'vault_public_key_file']],
ipa_module_options=["delete_continue"],
)

ansible_module._ansible_debug = True
Expand Down Expand Up @@ -689,6 +691,8 @@ def main():
datafile_in = ansible_module.params_get("datafile_in")
datafile_out = ansible_module.params_get("datafile_out")

delete_continue = ansible_module.params_get("delete_continue")

action = ansible_module.params_get("action")
state = ansible_module.params_get("state")

Expand Down Expand Up @@ -921,6 +925,8 @@ def main():
args = {
k: v for k, v in args.items() if k not in remove
}
if delete_continue:
args["continue"] = delete_continue
commands.append([name, "vault_del", args])

elif action == "member":
Expand Down
2 changes: 2 additions & 0 deletions tests/vault/env_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- symvault
- asymvault
username: "{{ username }}"
continue: yes
state: absent
loop:
- admin
Expand All @@ -21,6 +22,7 @@
name:
- sharedvault
- svcvault
continue: yes
state: absent

- name: Ensure test users do not exist.
Expand Down
4 changes: 4 additions & 0 deletions tests/vault/test_vault_asymmetric.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
ipaadmin_password: SomeADMINpassword
name: asymvault
state: absent
continue: no
register: result
failed_when: not result.changed or result.failed

Expand All @@ -235,6 +236,7 @@
ipaadmin_password: SomeADMINpassword
name: asymvault
state: absent
continue: no
register: result
failed_when: result.changed or result.failed

Expand Down Expand Up @@ -287,6 +289,7 @@
ipaadmin_password: SomeADMINpassword
name: asymvault
state: absent
continue: yes
register: result
failed_when: not result.changed or result.failed

Expand All @@ -295,6 +298,7 @@
ipaadmin_password: SomeADMINpassword
name: asymvault
state: absent
continue: yes
register: result
failed_when: result.changed or result.failed

Expand Down
2 changes: 2 additions & 0 deletions tests/vault/test_vault_standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
ipaadmin_password: SomeADMINpassword
name: stdvault
state: absent
continue: no
register: result
failed_when: not result.changed or result.failed

Expand All @@ -134,6 +135,7 @@
ipaadmin_password: SomeADMINpassword
name: stdvault
state: absent
continue: no
register: result
failed_when: result.changed or result.failed

Expand Down
4 changes: 4 additions & 0 deletions tests/vault/test_vault_symmetric.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
ipaadmin_password: SomeADMINpassword
name: symvault
state: absent
continue: no
register: result
failed_when: result.failed or not result.changed

Expand All @@ -146,6 +147,7 @@
ipaadmin_password: SomeADMINpassword
name: symvault
state: absent
continue: no
register: result
failed_when: result.failed or result.changed

Expand Down Expand Up @@ -293,6 +295,7 @@
ipaadmin_password: SomeADMINpassword
name: symvault
state: absent
continue: yes
register: result
failed_when: result.failed or not result.changed

Expand All @@ -301,6 +304,7 @@
ipaadmin_password: SomeADMINpassword
name: symvault
state: absent
continue: yes
register: result
failed_when: result.failed or result.changed

Expand Down