Last active
September 30, 2016 14:39
-
-
Save tychay/e86245d7652a755552ec to your computer and use it in GitHub Desktop.
Ansible 2.0 with Digital Ocean v2
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
$ 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 |
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
$ sudo pip install dopy |
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
$ export DO_API_VERSION='2' | |
$ export DO_API_TOKEN='api_token' |
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
--- | |
- 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 |
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
$ ansible-playbook provision.yml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mine fails... added API key and SSH but not working.