Skip to content

Instantly share code, notes, and snippets.

@ZECTBynmo
Last active October 31, 2015 20:29
Show Gist options
  • Save ZECTBynmo/394b3f5ed3d4b96bcd62 to your computer and use it in GitHub Desktop.
Save ZECTBynmo/394b3f5ed3d4b96bcd62 to your computer and use it in GitHub Desktop.
Ansible playlist to install docker and set things up
---
- name: Install docker
hosts: all
sudo: yes
tasks:
- name: add docker apt key
apt_key: >
id=2C52609D
url=https://apt.dockerproject.org/gpg
state=present
- name: add docker apt repository
apt_repository: >
repo="deb https://apt.dockerproject.org/repo ubuntu-{{ansible_distribution_release}} main"
state=present
update_cache=yes
- name: install docker
apt: pkg=docker-engine state=latest
- name: configure docker
copy: content='DOCKER_OPTS=""'
dest=/etc/default/docker
notify: restart docker
- name: allow vagrant user to run docker commands without sudo
user: name=vagrant append=yes groups=docker
- name: install required python packages for ansible and docker
apt: pkg={{item}} state=latest
with_items: [python-pip, python-dev]
# As of ansible v1.9.1, the docker module uses an older version of the docker-py package.
# https://github.com/ansible/ansible-modules-core/issues/1227
- name: install the version of docker-py used by ansible
pip: name=docker-py version=1.1.0
handlers:
# I can't use the service module because of an issue with ansible and upstart :(
# https://github.com/ansible/ansible-modules-core/issues/1170
- name: restart docker
command: service docker restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment