Open skwde opened 2 years ago
+
Thank you for this bug report. I just want to note that here is the related source code, if you want to hack on this:
https://github.com/ansible-collections/ansible.posix/blob/main/plugins/modules/authorized_key.py
Ok, I had another look at this. It turns out, that
Ok, I had another look at this. It turns out, that
* duplicate lines (comments / regular public key entries) are removed * (some) empty lines are removed * the order of the handled ssh key is changed, e.g. when changing the comment
Yes there is definitely room for improvement in that Python script. Probably with a bold partial rewrite, without staying too long to understand the original logic that clearly has too many unwanted situations
https://github.com/ansible-collections/ansible.posix/blob/main/plugins/modules/authorized_key.py
The goals are:
description
option was unset, or if we are in "add" more, never remove any comment (keep any "duplicate")
SUMMARY
Some empty lines / comments are removed + order of line is changed (when a change is done)
ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
Ensure you have a
~/.ssh/authorized_keys
with several lines, new lines and (multiline) comments which will be changed by below playbook. Running below playbook will reorder the entries and remove random comment lines / empty lines.EXPECTED RESULTS
Only the line corresponding to the actual sshkey is touched.
ACTUAL RESULTS
Running