Git Product home page Git Product logo

deploy-digital-ocean's Introduction

deploy-digital-ocean

Build Status

Create droplets within the Digital Ocean ecosystem. Tag all droplets to ansible managed tag, return the ip address and droplet ID.

Requirements

This role does require you to install the dopy python module.

pip install -r requirements.txt

The role will handle creating the ssh key if the do_ssh_key_id is undefined. When using an existing ssh key already within your Digital Ocean account you will need to retrieve the key id and set the variable.

do_ssh_key_id: number

To find your ssh key id you can make a simple GET request to the /v2/account/keys api. API docs can be found here

Role Variables

We require the following variable to be set when including the role. I would suggest setting this variable within a vault file inside your host_vars directory for the endpoint that will be running this play.

do_api_key: string

When the do_ssh_key_id variable is undefined we will check the local system for a public key. When a key is found it will be loaded into your DigitalOcean account. When the key fingerprint matches another key the role will fail since we don't want to step onto of your existing settings. By default the role will look in ~/.ssh/id_rsa.pub, this value can be overridden by setting the local_pub_key variable to another file. The key name in your DO account will beansible_crtl_hostname of the server this role was executed on.

local_pub_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"

The below variables are set within the defaults directory. These can be overridden if you need to deploy a bigger droplet or change your droplet name or region.

do_api_key: "{{ vault_do_api_key }}"
do_ssh_key_id: "{{ vault_do_ssh_key_id }}"
do_ssh_key_name: "ansible_crtl_{{ ansible_hostname }}"
droplet_name: 
    - dev0ansible
droplet_size: 512mb
do_region: nyc3
droplet_image_id: centos-6-x64
do_tag_name: ansible_mng

The do_ssh_key_name is used when adding your localhost ssh key to your Digital Ocean account. This will only run when do_ssh_key_id is undefined. When the role executes it will add the ssh key if the key finger print isn't found within your account. For each subsequent run the ssh_key_id will be used. This basically allows you to create an ansible_crtl_hostname key and use that key going forward.

The droplet_name is a list and will default to a single host called dev0ansible. You can increase the number of hosts by adding additional hostnames to your role arguments {"droplet_name":["dev1ansible","dev2ansible"]}

During the droplet provision process two facts will be set within your environment; ddo_group will contain the host ip address and droplet_id will contain the ID. These facts can be used to perform additional operations against the droplet.

Example Playbook

Simple role include example:

    - hosts: localhost
      connection: local
      roles:
         - { role: toilops.deploy-digital-ocean, droplet_name: ["dev2ansible","dev3ansible"] }

License

BSD

Author Information

Find me on github @BondAnthony

deploy-digital-ocean's People

Contributors

bondanthony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

gomex

deploy-digital-ocean's Issues

Fix bad ssh key variable

local_pub_key is loading as undefined, this value you needs to look for the localhosts public key. When the public key is already being used within DO we need to failover to using the key's id. Update documentation to reflect the public key dependency.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.