Skip to content

Instantly share code, notes, and snippets.

@t2ru
Last active August 29, 2015 14:01
Show Gist options
  • Save t2ru/25ebcd1fff051198cc43 to your computer and use it in GitHub Desktop.
Save t2ru/25ebcd1fff051198cc43 to your computer and use it in GitHub Desktop.
---
- hosts:
- servers
vars:
ansible_ssh_user: root
tasks:
- name: make sure local keys directory exists
local_action: file path=./keys state=directory
- name: check key pair exists
local_action: command test -f keys/id_rsa
failed_when: false
register: key_pair_exists
changed_when: key_pair_exists.rc != 0
- name: generating ssh key pair
local_action: shell ssh-keygen -t rsa -f keys/id_rsa -N ""
when: key_pair_exists|changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment