openssh_cert - fix full_idempotence for host certificates (#396) (#397)

* fixing host cert idempotence

* adding changelog fragment

(cherry picked from commit a307618872)
This commit is contained in:
Andrew Pantuso
2022-02-05 04:00:07 -05:00
committed by GitHub
parent 2727b74cc7
commit 7ff067937a
3 changed files with 28 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
bugfixes:
- openssh_cert - fixed false ``changed`` status for ``host`` certificates when using ``full_idempotence``
(https://github.com/ansible-collections/community.crypto/issues/395,
https://github.com/ansible-collections/community.crypto/pull/396).

View File

@@ -379,7 +379,7 @@ class Certificate(OpensshModule):
def _is_fully_valid(self):
return self._is_partially_valid() and all([
self._compare_options(),
self._compare_options() if self.original_data.type == 'user' else True,
self.original_data.key_id == self.identifier,
self.original_data.public_key == self._get_key_fingerprint(self.public_key),
self.original_data.signing_key == self._get_key_fingerprint(self.signing_key),

View File

@@ -86,6 +86,27 @@
regenerate: full_idempotence
register: default_options
- name: Generate host cert full_idempotence
openssh_cert:
type: host
path: "{{ certificate_path }}"
public_key: "{{ public_key }}"
signing_key: "{{ signing_key }}"
valid_from: always
valid_to: forever
regenerate: full_idempotence
- name: Generate host cert full_idempotence again
openssh_cert:
type: host
path: "{{ certificate_path }}"
public_key: "{{ public_key }}"
signing_key: "{{ signing_key }}"
valid_from: always
valid_to: forever
regenerate: full_idempotence
register: host_cert_full_idempotence
- name: Assert options results
assert:
that:
@@ -95,6 +116,7 @@
- explicit_extension_after is not changed
- explicit_extension_and_directive is changed
- default_options is not changed
- host_cert_full_idempotence is not changed
- name: Remove certificate
openssh_cert: