Skip to main content

read ansible yaml inventory, create droplets

Project description

dofaucet

tl;dr

Read YAML-formatted ansible inventory, create digitalocean droplets accordingly.

Neat tricks:

  • creates DNS records for both internal and external droplet IPs
  • adds ssh pubkeys to droplets (only keys already uploaded to DO)
  • adds alls created droplets to a project so they're easy to identify

Example usage

Inventory

foo.yml

all:
  vars:
    do_ssh_key_names: ['my_key', 'my_friends_key']
    dofaucet_dnsroot: example.com
    do_project: test_webstack_ansible
    do_image_slug: fedora-28-x64

foohosts:
  vars:
    do_tags: foohosts
  hosts:
    foo.infra.example.com

barhosts:
  vars:
    do_tags: barhosts
    # the bar app needs more ram
    do_size_slug: s-1vcpu-2gb
  hosts:
    bar.infra.example.com

dofaucet CLI

dofaucet --token 23234242 --project foo --inventory foo.yml

future ideas

Ansible is python3, so we could use the native ansible functionality to parse the inventory. Example code:

from ansible.parsing.dataloader import DataLoader
from ansible.vars.manager import VariableManager
from ansible.inventory.manager import InventoryManager

loader = DataLoader()
inventory = InventoryManager(loader=loader, sources='~/inventory.yml')
variable_manager = VariableManager(loader=loader, inventory=inventory)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dofaucet, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size dofaucet-0.0.2-py3-none-any.whl (7.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dofaucet-0.0.2.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page