Skip to content

Instantly share code, notes, and snippets.

@Zooloo2014
Created February 18, 2019 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zooloo2014/29c7552b31f5069669caae7b5d1d2f82 to your computer and use it in GitHub Desktop.
Save Zooloo2014/29c7552b31f5069669caae7b5d1d2f82 to your computer and use it in GitHub Desktop.
Ansible role for checking existence of SSH key on target
---
- set_fact: do_token="{{ lookup('env', 'DO_API_TOKEN')}}"
- set_fact: ssh_key_name="{{ lookup('env', 'SSH_KEY_NAME')}}"
- name: ensure ssh key exists and get the key id
digital_ocean:
state: present
command: ssh
name: my_ssh_key
ssh_pub_key: "{{ lookup('file', '{{ ssh_key_name }}.pub') }}"
register: my_ssh_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment