Skip to content

Instantly share code, notes, and snippets.

@tychay
Last active September 30, 2016 14:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tychay/e86245d7652a755552ec to your computer and use it in GitHub Desktop.
Save tychay/e86245d7652a755552ec to your computer and use it in GitHub Desktop.
Ansible 2.0 with Digital Ocean v2
$ git clone git://github.com/ansible/ansible.git --recursive
$ cd ansible
$ source ./hacking/env-setup
$ sudo pip install paramiko PyYAML Jinja2 httplib2 six
$ make
$ sudo make install
$ sudo pip install dopy
$ export DO_API_VERSION='2'
$ export DO_API_TOKEN='api_token'
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: create new Droplet
digital_ocean:
#api_token:
state: present
command: droplet
name: ansible-test
region_id: nyc3
size_id: 512mb
image_id: ubuntu-14-04-x64
ssh_key_ids:
# add your ssh key signature here
- "df:69:01:08:58:0c:48:f4:88:e7:5c:e7:07:95:70:a9"
backups_enabled: no
#ipv6: yes
#user_data: null
# Need to turn off private networking to guarantee ip_address is public
#private_networking: yes
# Requried for idempotence/only one droplet creation
unique_name: yes
register: do
- name: debug
debug: var=do
- name: Add new host to our inventory.
add_host:
name: "{{do.droplet.ip_address}}"
groups: do
when: do.droplet is defined
- hosts: do
remote_user: root
gather_facts: false
tasks:
- name: Wait for port 22 to become available.
local_action: "wait_for port=22 host={{ inventory_hostname }}"
- name: Install tcpdump.
apt: name=tcpdump state=present
$ ansible-playbook provision.yml
@dminca
Copy link

dminca commented Sep 30, 2016

PLAY [localhost] ***************************************************************                                                                               

TASK [create new Droplet] ******************************************************                                                                               
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: name 'DoError' is not defined                      
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_cu8nmy/ansible_mo
dule_digital_ocean.py\", line 187, in <module>\n    class TimeoutError(DoError):\nNameError: name 'DoError' is not defined\n", "module_stdout": "", "msg": "MOD
ULE FAILURE"}                                                                                                                                                  

NO MORE HOSTS LEFT *************************************************************                                                                               
        to retry, use: --limit @/home/dminca/Repos/open-source/containerschiff/digiocean.retry                                                                 

PLAY RECAP *********************************************************************                                                                               
localhost                  : ok=0    changed=0    unreachable=0    failed=1                                                                                    

mine fails... added API key and SSH but not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment