Skip to content

Commit

Permalink
Check if ssh keys exists before creating a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Nov 21, 2023
1 parent 0ea464c commit 67ce8f1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions roles/ssh/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@
state: directory
mode: '700'

- name: Register work ssh
stat:
path: ~/.ssh/id_ed25519_work
register: work_ssh

- name: Generate an OpenSSH keypair for professional projects
when: "not work_ssh.stat.exists"
community.crypto.openssh_keypair:
path: ~/.ssh/id_ed25519_work
type: ed25519

- name: Register personal ssh
stat:
path: ~/.ssh/id_ed25519_personal
register: personal_ssh

- name: Generate an OpenSSH keypair for personal projects
when: "not personal_ssh.stat.exists"
community.crypto.openssh_keypair:
path: ~/.ssh/id_ed25519_personal
type: ed25519
Expand Down

0 comments on commit 67ce8f1

Please sign in to comment.