Digital Ocean Vagrant Provider For Chassis
vagrant-chassis-digitalocean
is a provider plugin for Vagrant that supports the
management of Digital Ocean droplets
(instances) that setup WordPress using Chassis.
NOTE: The Chef provisioner is no longer supported by default (as of 0.2.0).
Please use the vagrant-omnibus
plugin to install Chef on Vagrant-managed
machines. This plugin provides control over the specific version of Chef
to install.
Current features include:
- create and destroy droplets
- power on and off droplets
- rebuild a droplet
- provision a droplet with the shell or Chef provisioners
- setup a SSH public key for authentication
- create a new user account during droplet creation
Install
Installation of the provider requires two steps:
Install the provider plugin using the Vagrant command-line interface:
$ vagrant plugin install vagrant-chassis-digitalocean
NOTE: If you are using a Mac, you may need to install a CA bundle to enable SSL communication with the Digital Ocean API. It is recommended to first install Homebrew. With Homebrew installed, run the following command to install the bundle:
$ brew install curl-ca-bundle
Once the bundle is installed, add the following environment variable to your
.bash_profile
script and source
it:
export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem
Configure
Once the provider has been installed, you will need to configure your Chassis project
to use it. You can use your we recommend adding your Digital Ocean details in your projects config.yaml
or config.local.yaml
file:
digitalocean:
token: 'YOUR TOKEN'
region: 'sgp1'
size: '512mbB'
image: 'Ubuntu 14.04 x64'
You must also add the following to your project VagrantFile
config.vm.provider :chassis_digitalocean do |provider, override|
override.ssh.private_key_path = '~/.ssh/id_rsa'
override.vm.box_url = 'https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digitalocean.box'
provider.token = CONF['digitalocean']['token']
provider.image = CONF['digitalocean']['image']
provider.region = CONF['digitalocean']['region']
provider.size = CONF['digitalocean']['size']
end
Optionally, you can remove exclude your .git folder from the rsync by including the following line after you've specified your
config.vm.synced_folder
rsync__exclude: ".git/"
Please note the following:
- You must specify the
override.ssh.private_key_path
to enable authentication with the droplet. The provider will create a new Digital Ocean SSH key using your public key which is assumed to be theprivate_key_path
with a .pub extension. - You must specify your Digital Ocean Personal Access Token. This may be found on the control panel within the Apps & API section.
Supported Configuration Attributes
The following attributes are available to further configure the provider:
provider.image
- A string representing the image to use when creating a new droplet (e.g.Debian 6.0 x64
). The available options may be found on Digital Ocean's new droplet form. It defaults toUbuntu 14.04 x64
.provider.ipv6
- A boolean flag indicating whether to enable IPv6provider.region
- A string representing the region to create the new droplet in. It defaults tonyc2
.provider.size
- A string representing the size to use when creating a new droplet (e.g.1gb
). It defaults to512mb
.provider.private_networking
- A boolean flag indicating whether to enable a private network interface (if the region supports private networking). It defaults tofalse
.provider.backups_enabled
- A boolean flag indicating whether to enable backups for the droplet. It defaults tofalse
.provider.ssh_key_name
- A string representing the name to use when creating a Digital Ocean SSH key for droplet authentication. It defaults toVagrant
.provider.setup
- A boolean flag indicating whether to setup a new user account and modify sudo to disable tty requirement. It defaults totrue
. If you are using a tool like packer to create reusable snapshots with user accounts already provisioned, set tofalse
.
The provider will create a new user account with the specified SSH key for
authorization if config.ssh.username
is set and the provider.setup
attribute is true
.
provider.region slug
Each region has been specify with slug name.
Current Region-slug table is:
slug | Region Name |
---|---|
nyc1 | New York 1 |
ams1 | Amsterdam 1 |
sfo1 | San Francisco 1 |
nyc2 | New York 2 |
ams2 | Amsterdam 2 |
sgp1 | Singapore 1 |
lon1 | London 1 |
nyc3 | New York 3 |
You can find latest region slug name using DigitalOcean API V2 call.
- example call.
curl -X GET "https://api.digitalocean.com/v2/regions" \
-H "Authorization: Bearer $DIGITAL_OCEAN_TOKEN" \
2>/dev/null | jq '.regions [] | .slug,.name'
More detail: DigitalOcean API - Regions
Run
After creating your project's Vagrantfile
with the required configuration
attributes described above, you may create a new droplet with the following
command:
$ vagrant up --provider=chassis_digitalocean
This command will create a new droplet, setup your SSH key for authentication, create a new user account, and run the provisioners you have configured.
Supported Commands
The provider supports the following Vagrant sub-commands:
vagrant destroy
- Destroys the droplet instance.vagrant ssh
- Logs into the droplet instance using the configured user account.vagrant halt
- Powers off the droplet instance.vagrant provision
- Runs the configured provisioners and rsyncs any specifiedconfig.vm.synced_folder
.vagrant reload
- Reboots the droplet instance.vagrant rebuild
- Destroys the droplet instance and recreates it with the same IP address is was assigned to previously.vagrant status
- Outputs the status (active, off, not created) for the droplet instance.
Contribute
To contribute, clone the repository, and use Bundler to install dependencies:
$ bundle
To run the provider's tests:
$ bundle exec rake test
You can now make modifications. Running vagrant
within the Bundler
environment will ensure that plugins installed in your Vagrant
environment are not loaded.