Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ansible FreeIPA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Ansible FreeIPA
Commits
0af8f35e
Unverified
Commit
0af8f35e
authored
4 years ago
by
Thomas Woerner
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #334 from rjeffman/fix_ipavault_salt_update
Fix ipavault `salt` update.
parents
9a3f08b6
3c2700f6
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README-vault.md
+1
-1
1 addition, 1 deletion
README-vault.md
plugins/modules/ipavault.py
+19
-10
19 additions, 10 deletions
plugins/modules/ipavault.py
tests/vault/test_vault_symmetric.yml
+54
-17
54 additions, 17 deletions
tests/vault/test_vault_symmetric.yml
with
74 additions
and
28 deletions
README-vault.md
+
1
−
1
View file @
0af8f35e
...
...
@@ -197,7 +197,7 @@ Example playbook to make sure vault is absent:
state: absent
register: result
-
debug:
msg: "{{ result.data }}"
msg: "{{ result.
vault.
data }}"
```
Variables
...
...
This diff is collapsed.
Click to expand it.
plugins/modules/ipavault.py
+
19
−
10
View file @
0af8f35e
...
...
@@ -243,7 +243,7 @@ EXAMPLES = """
state: retrieved
register: result
- debug:
msg:
"
{{ result.data }}
"
msg:
"
{{ result.
vault.
data }}
"
# Change password of a symmetric vault
- ipavault:
...
...
@@ -494,8 +494,10 @@ def check_encryption_params(module, state, action, vault_type, salt,
new_password
,
new_password_file
,
res_find
):
vault_type_invalid
=
[]
if
res_find
is
not
None
:
if
vault_type
is
None
and
res_find
is
not
None
:
vault_type
=
res_find
[
'
ipavaulttype
'
]
if
isinstance
(
vault_type
,
(
tuple
,
list
)):
vault_type
=
vault_type
[
0
]
if
vault_type
==
"
standard
"
:
vault_type_invalid
=
[
'
public_key
'
,
'
public_key_file
'
,
'
password
'
,
...
...
@@ -515,6 +517,16 @@ def check_encryption_params(module, state, action, vault_type, salt,
module
.
fail_json
(
msg
=
"
Cannot modify password of inexistent vault.
"
)
if
(
salt
is
not
None
and
not
(
any
([
password
,
password_file
])
and
any
([
new_password
,
new_password_file
])
)
):
module
.
fail_json
(
msg
=
"
Vault `salt` can only change when changing the password.
"
)
if
vault_type
==
"
asymmetric
"
:
vault_type_invalid
=
[
'
password
'
,
'
password_file
'
,
'
new_password
'
,
'
new_password_file
'
...
...
@@ -766,7 +778,12 @@ def main():
commands
.
append
([
name
,
"
vault_mod_internal
"
,
args
])
else
:
if
vault_type
==
'
symmetric
'
\
and
'
ipavaultsalt
'
not
in
args
:
args
[
'
ipavaultsalt
'
]
=
os
.
urandom
(
32
)
commands
.
append
([
name
,
"
vault_add_internal
"
,
args
])
if
vault_type
!=
'
standard
'
and
vault_data
is
None
:
vault_data
=
''
...
...
@@ -824,14 +841,6 @@ def main():
commands
.
append
(
[
name
,
'
vault_remove_owner
'
,
owner_del_args
])
if
vault_type
==
'
symmetric
'
\
and
'
ipavaultsalt
'
not
in
args
:
args
[
'
ipavaultsalt
'
]
=
os
.
urandom
(
32
)
if
vault_type
==
'
symmetric
'
\
and
'
ipavaultsalt
'
not
in
args
:
args
[
'
ipavaultsalt
'
]
=
os
.
urandom
(
32
)
elif
action
in
"
member
"
:
# Add users and groups
if
any
([
users
,
groups
,
services
]):
...
...
This diff is collapsed.
Click to expand it.
tests/vault/test_vault_symmetric.yml
+
54
−
17
View file @
0af8f35e
...
...
@@ -178,6 +178,15 @@
register
:
result
failed_when
:
result.vault.data != 'Hello World.' or result.changed
-
name
:
Retrieve data from symmetric vault, with wrong password.
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
symvault
password
:
SomeWRONGpassword
state
:
retrieved
register
:
result
failed_when
:
not result.failed or "Invalid credentials" not in result.msg
-
name
:
Change vault password.
ipavault
:
ipaadmin_password
:
SomeADMINpassword
...
...
@@ -187,51 +196,79 @@
register
:
result
failed_when
:
not result.changed
-
name
:
Retrieve data from symmetric vault, with
wrong
password.
-
name
:
Retrieve data from symmetric vault, with
new
password.
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
symvault
password
:
Some
VAULT
password
password
:
Some
NEW
password
state
:
retrieved
register
:
result
failed_when
:
not
result.
failed or "Invalid credentials" not in
result.
msg
failed_when
:
result.
vault.data != 'Hello World.' or
result.
changed
-
name
:
Change vault password, with wrong `
old
_
password
`
.
-
name
:
Retrieve data from symmetric vault, with
old
password.
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
symvault
password
:
SomeVAULTpassword
new_password
:
SomeNEWpasswor
d
state
:
retrieve
d
register
:
result
failed_when
:
not result.failed or "Invalid credentials" not in result.msg
-
name
:
Retrieve data from
symmetric vault
, with new
password
.
-
name
:
Change
symmetric vault
salt, changing
password
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
symvault
password
:
SomeNEWpassword
state
:
retrieved
new_password
:
SomeVAULTpassword
salt
:
AAAAAAAAAAAAAAAAAAAAAAA=
register
:
result
failed_when
:
result.vault.data != 'Hello World.' or
result.changed
failed_when
:
not
result.changed
-
name
:
Try to add vau
lt with
multiple
password
s.
-
name
:
Change symmetric vault sa
lt
,
with
out changing
password
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
inexistent
vault
name
:
sym
vault
password
:
SomeVAULTpassword
password_file
:
"
{{
ansible_env.HOME
}}/password.txt"
new_password
:
SomeVAULTpassword
salt
:
MTIzNDU2Nzg5MDEyMzQ1Ngo=
register
:
result
failed_when
:
not result.
failed or "parameters are mutually exclusive" not in result.msg
failed_when
:
not result.
changed
-
name
:
Try to
add vault with multiple new
password
s.
-
name
:
Try to
change symmetric vault salt, without providing any
password
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
inexistentvault
password
:
SomeVAULTpassword
name
:
symvault
salt
:
MTIzNDU2Nzg5MDEyMzQ1Ngo=
register
:
result
failed_when
:
not result.failed and "Vault `salt` can only change when changing the password." not in result.msg
-
name
:
Try to change symmetric vault salt, without providing `password`
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
symvault
salt
:
MTIzNDU2Nzg5MDEyMzQ1Ngo=
new_password
:
SomeVAULTpassword
new_password_file
:
"
{{
ansible_env.HOME
}}/password.txt"
register
:
result
failed_when
:
not result.failed or "parameters are mutually exclusive" not in result.msg
failed_when
:
not result.failed and "Vault `salt` can only change when changing the password." not in result.msg
-
name
:
Try to change symmetric vault salt, without providing `new_password`
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
symvault
salt
:
MTIzNDU2Nzg5MDEyMzQ1Ngo=
password
:
SomeVAULTpassword
register
:
result
failed_when
:
not result.failed and "Vault `salt` can only change when changing the password." not in result.msg
-
name
:
Try to change symmetric vault salt, using wrong password.
ipavault
:
ipaadmin_password
:
SomeADMINpassword
name
:
symvault
password
:
SomeWRONGpassword
new_password
:
SomeWRONGpassword
salt
:
MDEyMzQ1Njc4OTAxMjM0NQo=
register
:
result
failed_when
:
not result.failed
-
name
:
Ensure symmetric vault is absent
ipavault
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment