Skip to content

Instantly share code, notes, and snippets.

@juliedavila
Created November 12, 2015 23:16
Show Gist options
  • Save juliedavila/adb8e6f4b3dc099ff905 to your computer and use it in GitHub Desktop.
Save juliedavila/adb8e6f4b3dc099ff905 to your computer and use it in GitHub Desktop.
key rotation for autologic_users
- name: Move original key
command: mv files/sshkeys/{{item.value.username}}.priv files/sshkeys/{{item.value.username}}.priv.last
args:
removes: files/sshkeys/{{item.value.username}}.priv
delegate_to: localhost
with_dict: autologic_system_users
run_once: yes
when: rotate
- name: Move old pub key
command: mv files/sshkeys/{{item.value.username}} files/sshkeys/{{item.value.username}}.pub.last
delegate_to: localhost
with_dict: autologic_system_users
run_once: yes
when: rotate
- name: Generate New Keys
command: ssh-keygen -t rsa -N "" -f files/sshkeys/{{item.value.username}}
delegate_to: localhost
with_dict: autologic_system_users
run_once: yes
when: rotate
- name: Rename priv key
command: mv files/sshkeys/{{item.value.username}} files/sshkeys/{{item.value.username}}.priv
delegate_to: localhost
with_dict: autologic_system_users
run_once: yes
when: rotate
- name: Rename Pub key
command: mv files/sshkeys/{{item.value.username}}.pub files/sshkeys/{{item.value.username}}
delegate_to: localhost
with_dict: autologic_system_users
when: rotate
run_once: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment