This is a experiment to see how to provision and transfer images to a vagrant box using ansible.
- prepare_server.yml
- Installs aufs driver for ubuntu
- Hardens the server (firewall, auth...)
- Installs docker
- setup.yml
- Download and start postgres container
- Add config for nginx
- deploy.yml
- Retrive app version
- Build app image
- Transfer app image to remote
- Stop and remove previous app container
- Tag new image as 'latest'
- Clear up old releases
- Start app container
- Start/restart nginx container
-
Connect to vagrant using ssh
ssh $(vagrant ssh-config | awk '{print " -o "$1"="$2}') localhost
(alt tovagrant ssh
)
-
Transfer local image to remote
docker save <image_id> | bzip2 | ssh $(vagrant ssh-config | awk '{print " -o "$1"="$2}') localhost 'bunzip2 | docker load'
-
Transfer local image to remote (with progress)
docker save <image_id> | bzip2 | pv | ssh $(vagrant ssh-config | awk '{print " -o "$1"="$2}') localhost 'bunzip2 | docker load'
-
Run deploy playbook
ansible-playbook ./ansible/deploy.yml -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory -u vagrant
- Ping vagrant machine
ansible all -m ping -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory -u vagrant