Skip to content

Commit

Permalink
openssh_keypair: Populate return values when keypair exists and check…
Browse files Browse the repository at this point in the history
…_mode=true (#230)

* Swapping statement order for check_mode to initialize return values

* Adding changelog fragment

* Updated changelog to reflect bugfix
  • Loading branch information
Ajpantuso authored May 12, 2021
1 parent 3e73622 commit 80d64e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- openssh_keypair - fix ``check_mode`` to populate return values for existing keypairs (https://github.com/ansible-collections/community.crypto/issues/113, https://github.com/ansible-collections/community.crypto/pull/230).
3 changes: 2 additions & 1 deletion plugins/modules/openssh_keypair.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,9 @@ def main():
if keypair.state == 'present':

if module.check_mode:
changed = keypair.force or not keypair.isPrivateKeyValid(module) or not keypair.isPublicKeyValid(module)
result = keypair.dump()
result['changed'] = keypair.force or not keypair.isPrivateKeyValid(module) or not keypair.isPublicKeyValid(module)
result['changed'] = changed
module.exit_json(**result)

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- privatekey1_result_check is changed
- privatekey1_result is changed
- privatekey1_idem_result_check is not changed
- privatekey1_idem_result_check.public_key.startswith("ssh-rsa")
- privatekey1_idem_result is not changed

- name: Validate privatekey1 return fingerprint
Expand Down

0 comments on commit 80d64e7

Please sign in to comment.