Ansible: Change SSH key -


i have inventory of multiple servers. ssh access these servers secured using pem key files. periodically change pem key used servers. so, use ansible following:

  1. generate new pem key file
  2. for each server in inventory, connect server using old pem key file
  3. install new pem key file
  4. test ensure ssh new key works , old key does not work

what best way via ansible?

you should split in 3 playbooks.

the first generate new pem key. run locally. see: https://docs.ansible.com/ansible/playbooks_delegation.html#local-playbooks

the second 1 rollout. copies key servers. can use authorized_key or copy depending on preferred workflow is. thats question.

the third step testing playbook, maybe assert statement or using ping ensure connection works.

when have playbooks combine them in single include or add 3 plays in 1 playbook in right order. see: https://docs.ansible.com/ansible/playbooks_intro.html


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -