Created
September 29, 2013 03:49
-
-
Save blocke/6749194 to your computer and use it in GitHub Desktop.
Simple Ansible playbook for demonstrating spinning up a VM on DigitalOcean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Invoke this twice: | |
# 1. Invoke with an inventory file containing nothing but 'localhost' | |
# 2. Invoke with digital_ocean.py inventory plugin as the inventory | |
# ansible-playbook -i localhost.inv equestria.yml && ansible-playbook -i digital_ocean.py equestria.yml | |
# Ansible 1.4 (github devel) required for unique_name option | |
- hosts: localhost | |
connection: local | |
sudo: no | |
gather_facts: no | |
tasks: | |
- name: Add SSH key to DigitalOcean account | |
digital_ocean: > | |
state=present | |
command=ssh | |
name=laptop_ssh_key | |
ssh_pub_key='{{ lookup('file', '/home/blocke/.ssh/id_rsa.pub') }}' | |
client_id={{ lookup('file', '/home/blocke/.do-client_id') }} | |
api_key={{ lookup('file', '/home/blocke/.do-api_key') }} | |
register: do_ssh_key | |
# Ubuntu_13.04_x64 512MB VM in New_York2 | |
- name: Create DO VM for Equestria | |
digital_ocean: > | |
state=present | |
command=droplet | |
name=equestria | |
region_id=4 | |
image_id=350076 | |
size_id=66 | |
wait=yes | |
unique_name=yes | |
ssh_key_ids={{ do_ssh_key.ssh_key.id }} | |
client_id={{ lookup('file', '/home/blocke/.do-client_id') }} | |
api_key={{ lookup('file', '/home/blocke/.do-api_key') }} | |
- hosts: equestria | |
user: root | |
tasks: | |
- name: Install packages | |
apt: name=nginx state=present | |
- name: start nginx | |
service: name=nginx state=started enabled=yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what does 'register: do_ssh_key' actually do and where does it come from?
I just get the error;
fatal: [localhost] => One or more undefined variables: 'do_ssh_key' is undefined