dometawrite

Visit site

A tool that helps system administrators use information from the DO API and/or Droplet Metadata to create configuration files by means of templates.

Templates are written using the most-excellent Jinja2 library for Python.

Example: Create SSH client configuration

dometawrite can be used to create an OpenSSH SSH Client configuration file that can be included from ~/.ssh/config for easy access to your droplets. Picture this:

~ $ dometawrite –template ssh-config
    –api-key $DO_API_KEY –output /home/example/.ssh/digitalocean_droplets -u user:remoteUser -u keyfile:/home/example/id_rsa_digitalocean

The above command will render the ssh-config dometawrite template, and write the output to the /home/example/.ssh/digitalocean_droplets file.

It will use the indicated DigitalOcean API KEY, and will also provide some additional variables to the template. If any variables are missing from the command line, dometawrite will let you know.

The resulting output may look like this:

Host droplet-name HostName droplet_ip_address User root IdentityFile /home/example/id_rsa_digitalocean

Host another_droplet HostName yet_another_ip User root IdentityFile /home/example/id_rsa_digitalocean

As long as the id_rsa_digitalocean.pub file has been added to the droplet, either during creation or afterwards, then you will be able to simply:

ssh root@another_droplet

Example: Create OpenSSH AuthorizedKeysFile-compatible output using from your DigitalOcean account.

This is a useful feature, but please do NOT –output directly to your authorized_keys file!

dometawrite –template authorizedkeys
    –api-key $DO_API_KEY

Example: Create ansible inventory (This template is not yet available)

Maybe you use ansible, and you want to update your hosts inventory dynamically:

dometawrite –template ansible-inventory
    –api-key $DO_API_KEY –output /etc/ansible/hosts/digitaloceaninventory

The template will receive a python dictionary with all necessary information. Jinja2 supports advanced logic, so it can easily contain all the required code to output a valid Ansible Inventory file.

Was this helpful?
 
Leave a comment


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Publish your Tool on Community

Have you created an Integration, API Wrapper, Service, or other Tool that helps developers build on DigitalOcean? Help users find it by listing it in Community Tools.

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more