SUMMARY
Add regex like lineinfile has it.
When we rotate the key we keep some of the comment the same, and it would be easy to rotate the key with a regex like lineinfil has it. Right now we either has to use lineinfile or remember all the old keys and make sure they are gone.
So in short replace the (first) line where the regex matches with the key OR add it to the end if none matches
ISSUE TYPE
COMPONENT NAME
authorized_key
ADDITIONAL INFORMATION
- name: Add authorized key to "ansible"
ansible.posix.authorized_key:
user: ansible
state: present
regex: "Bob @ Laptop"
key: "ssh-ed25519 AAAAAxxxxxxxxxxx Bob @ Laptop 20251017"
SUMMARY
Add regex like lineinfile has it.
When we rotate the key we keep some of the comment the same, and it would be easy to rotate the key with a regex like lineinfil has it. Right now we either has to use lineinfile or remember all the old keys and make sure they are gone.
So in short replace the (first) line where the regex matches with the key OR add it to the end if none matches
ISSUE TYPE
COMPONENT NAME
authorized_key
ADDITIONAL INFORMATION