mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
feat: allow recreating ssh key when public key in the API does not match (#634)
##### SUMMARY - Log a warning when the provided public key does not match one in the API. - When the public key does not match the one in the API, allow recreating the SSH Key in the API using the ``force=true`` argument. Closes: #578 ##### ISSUE TYPE - Feature Pull Request ##### COMPONENT NAME <!--- Write the short name of the module, plugin, task or feature below --> `ssh_key` ##### ADDITIONAL INFORMATION In Hetzner API, we do not have any public_key change endpoint and only updating names and labels are allowed. For public_key The only way is removing and re-creating. `force` option allows users to do re-creation if needed. --------- Co-authored-by: jo <ljonas@riseup.net>
This commit is contained in:
parent
1ec09d252d
commit
4fc2003f30
6 changed files with 121 additions and 2 deletions
27
tests/unit/module_utils/test_ssh.py
Normal file
27
tests/unit/module_utils/test_ssh.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from ansible_collections.hetzner.hcloud.plugins.module_utils.ssh import (
|
||||
ssh_public_key_md5_fingerprint,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("public_key", "fingerprint"),
|
||||
[
|
||||
(
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILNWUEdTk1oxrjUZ5erbKUmJM3VxQ9DLocgt/HFohCf6 comment",
|
||||
"ce:cf:37:b9:38:40:ad:80:b2:8b:2c:5c:83:b5:af:0b",
|
||||
),
|
||||
(
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILNWUEdTk1oxrjUZ5erbKUmJM3VxQ9DLocgt/HFohCf6", # No comment
|
||||
"ce:cf:37:b9:38:40:ad:80:b2:8b:2c:5c:83:b5:af:0b",
|
||||
),
|
||||
(
|
||||
"ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBABOUmmgxbhhauMg97GMwHcjWXM35MwFmlSKx7klWpPr3jMbabGQzINFVXexgf6Tru0D5a7NU/Hkx9t2yOtqKHJOIQB5/NKktqYelul4X56WYV/64RSm6xIjcolNao9fUbawnIwh9mvaQQg5v1BiJfPJ6p6LcWPunzfm6DztU1tHwLtjTw== comment", # noqa: E501
|
||||
"bf:61:7b:7f:ab:c7:af:25:aa:d7:d5:e8:5f:87:5c:66",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_ssh_public_key_md5_fingerprint(public_key: str, fingerprint: str):
|
||||
assert ssh_public_key_md5_fingerprint(public_key) == fingerprint
|
||||
Loading…
Add table
Add a link
Reference in a new issue