You must rotate the SSH key used by Ansible across all hosts without losing access.
AdvancedScenarioSecurity: Vault, Become and Compliance
Answer
Situation read → Key rotation with rollback safety.
What I'd do →
- Add the new public key (keep the old one).
- Verify login with the new key on every host.
- Switch the controller/AWX credential.
- Remove the old key.
- ansible.posix.authorized_key:
user: ansible
key: "{{ lookup('file', 'new_ansible.pub') }}"
state: present
# later
- ansible.posix.authorized_key:
user: ansible
key: "{{ lookup('file', 'old_ansible.pub') }}"
state: absent
Why → Overlap prevents lockouts.
Interview tip → Use exclusive: true only after you are sure.
More on Security: Vault, Become and Compliance
Database passwords are sitting in plain text in `group_vars`. How do you fix it?BeginnerYou need separate vault passwords for staging and prod.IntermediateHow do you change the vault password for all encrypted files?IntermediateA CI pipeline needs the vault password without storing it in the repo.IntermediateYou want to see the value inside an encrypted file without writing a decrypted copy to disk.BeginnerOnly one value in a vars file is secret and you want it in the same file as plain values.Beginner