Created
April 1, 2014 01:37
-
-
Save mattieb/9906124 to your computer and use it in GitHub Desktop.
First attempt to provision and configure a droplet with Ansible
This file contains hidden or 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
# First attempt to provision and configure a Digital Ocean droplet | |
# using Ansible. | |
# | |
# After you run this the first time, you have to fill in the droplet | |
# id it prints into the id= parameter of the digital_ocean task. From | |
# there on out it's idempotent. | |
- hosts: 127.0.0.1 | |
connection: local | |
gather_facts: False | |
tasks: | |
- name: provision | |
digital_ocean: > | |
client_id=YOUR_CLIENT_ID_HERE | |
api_key=YOUR_API_KEY_HERE | |
state=present | |
command=droplet | |
id=0 | |
name=YOUR_DROPLET_NAME_HERE | |
size_id=66 | |
region_id=4 | |
image_id=1505447 | |
wait_timeout=300 | |
ssh_key_ids=YOUR_SSH_KEY_ID_HERE | |
register: droplet | |
- debug: msg="droplet id is {{ droplet.droplet.id }}" | |
- name: collect public IP address | |
add_host: hostname={{ droplet.droplet.ip_address }} groupname=droplet_hosts | |
- hosts: droplet_hosts | |
user: root | |
tasks: | |
- name: install nginx | |
apt: pkg=nginx state=present | |
- name: enable nginx | |
service: name=nginx enabled=yes state=started |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment