What: Using Ansible to setup a development system with Couchdb and Docker
Why: Having a phoenix like dev setup
How: Using Ansible and some simple roles to provision the system
You need a system, where Ansible is installed on. In case you don’t have it at hand, you can use the following Vagrantfile to set it up:
Vagrant.configure("2") do |config| config.vm.box = "debian/jessie64" config.vm.synced_folder ".", "/vagrant", type: "virtualbox" config.vm.provision "shell", inline: <<-SHELL echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 sudo apt-get update sudo apt-get install -y ansible SHELL end
Preparing the playbook
Lets set up a simple playbook. Because something is installed, become is needed to install as root. Create a file called playbook.yml with the following content (there are more roles in the repository, but these should be enough for the beginning):
1 2 3 4 5 6 7 8 9 10 11
- name: playbook hosts: all become: true roles: - install-dockerce - install-docker-py - install-couch - install-java8 - install-maven - install-vim
Clone the following git repository and change to the directory usefulansibleroles. Copy the roles-folder next to your playbook file.
Note: The install-couch role will install couchdb via docker (see https://hub.docker.com/r/klaemo/couchdb/) in version 2.0. Docker will be setup to restart couchdb at every boot.
Run the playbook. You can use a hosts file at /etc/ansible/hosts or run it locally:
ansible-playbook -i "localhost," -c local playbook.yml
Connect to the provisioned machine. The following commands should give you correct results:
sudo docker run hello-world