This playbook can be used to quickly build/rebuild/destroy virtual servers located on the remote DigitalOcean droplet and based on Ubuntu 16.04 LTS. In case of DigitalOcean provisioning it creates a dynamic inventory, so there is no necessity to configure your Ansible connection.
To use this playbook, you will need to have done the following:
- Install Ansible, Ansible 2.2+ is required.
- Install dopy.
- Open a shell prompt (Terminal app on Mac) and cd into the cloned folder.
- Run the following command to install the necessary Ansible roles for this profile:
$ ansible-galaxy install -r requirements.yml
- Create your ssh key pair and fill their paths into
public_ssh_key_root
andprivate_ssh_key_root
variables (they can be both absolute or relative to thedo_provision.yml
file location).
If you will be using Vagrant local provisioning you should also do the following:
- Download and Install VirtualBox
- Download and Install Vagrant
To provision your local environment you can simply type vagrant up
(in the directory containing Vagrantfile
) and wait until Vagrant will create a new VM, install the base box, and configure it.
Once the Vagrant VM is up and runing (after vagrant up
is complete and you're back at the command prompt), you can log into via SSH with vagrant ssh
or with ssh -i ~/.vagrant.d/insecure_private_key jz@192.168.77.77
.
You should know your API token
from your DigitalOcean account and add it to vars.yml
file in vars
directory, or add it to DO_API_TOKEN
environment variable.
To provision your droplet just cd
into your cloned directory and run ansible-playbook do-provision.yml
, then you will be asked if you want your machine to be present
(created) or absent
(deleted) and just wait till everything is done with ansible.
To log into your server via SSH run ssh -i /path/to/your/public_ssh_key %your_user_name%@%created_droplet_ip%
.
If you have domain directed on DigitalOcean's rDNS you can also connect it to your droplet, all you need is to add domain_name
variable to vars/vars.yml
file.
There are default variables in vars/defaults.yml
file which can be overwritten in vars/vars.yml
file.
api_token
- it's needed for DigitalOcean provision.DO_API_TOKEN
environment variable can be also used instead.private_ssh_key_root
- path to your private ssh key (absolute or relative to*_provision.yml
file).public_ssh_key_root
- path to your public ssh key (absolute or relative to*_provision.yml
file).
mysql_databases:
- name: your_database_name
To create database you should add this variable to vars/vars.yml
file with your preferred name.
domain_name: ""
You can connect your own domain name to the DigitalOcean droplet if you will just declare this variable with your own domain name. Don't forget that you have previously to direct your domain provider's DNS on DigitalOcean's DNS.
droplet_name: ""
Name of the droplet, which will be shown in your web-interface.
user_name: ""
Name of user, which would be the main operating one, included in sudoers
file and the only one possible to connect to remote server , while root
login will be turned off.
user_pass: ""
The default password for jz
is also jz
if you would like to change it, you should put it in this document previously hashed it with SHA-512, this instruction will help you to deal with it.
mysql_user_pass: ""
Pass that will be used for connections to MySQL database, default value is jz
.
security_ssh_port: ""
Here you can choose your prefered port for ssh connections, the default one is 22
. If you are going to change it - also change ansible_ssh_port
variable in inventory_for_vagrant
file.
Other variables you can find in docs for the next roles from tenequm's github:
---
public_ssh_key_root: "~/.ssh/id_rsa.pub"
private_ssh_key_root: "~/.ssh/id_rsa"
MIT
This role was created in 2017 by Mykhaylo Kolesnik.