Skip to content

Commit

Permalink
Merge pull request #55 from dispansible/docker-compose-and-docker-gro…
Browse files Browse the repository at this point in the history
…up-members

Install docker-compose (via pip) and optionally add users to the docker group
  • Loading branch information
angstwad committed Jul 1, 2015
2 parents c94064b + 6ee8673 commit ec0e026
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,15 @@ apt_repository: deb https://get.docker.com/ubuntu docker main
# -H tcp://0.0.0.0:2375
# --log-level=debug
docker_opts: ""
# Versions for the python packages that are installed installed
# List of users to be added to 'docker' system group (disabled by default)
# SECURITY WARNING: 
# Be aware that granted users can easily get full root access on the docker host system!
docker_group_members: []
# Versions for the python packages that are installed
pip_version_pip: latest
pip_version_setuptools: latest
pip_version_docker_py: latest
pip_version_docker_compose: latest
# If this variable is set to true kernel updates and host restarts are permitted.
# Warning: Use with caution in production environments.
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

role = File.basename(File.expand_path(File.dirname(__FILE__)))

ENV['ANSIBLE_ROLES_PATH'] = "../../roles"
ENV['ANSIBLE_ROLES_PATH'] = "../"

boxes = [
{
Expand Down
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ apt_repository: deb https://get.docker.com/ubuntu docker main
# -H tcp://0.0.0.0:2375
# --log-level=debug
docker_opts: ""
# List of users to be added to 'docker' system group (disabled by default)
# SECURITY WARNING: 
# Be aware that granted users can easily get full root access on the docker host system!
docker_group_members: []
# Versions for the python packages that are installed installed
pip_version_pip: latest
pip_version_setuptools: latest
pip_version_docker_py: latest
pip_version_docker_compose: latest

# If this variable is set to true kernel updates and host restarts are permitted.
# Warning: Use with caution in production environments.
Expand Down
15 changes: 13 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,19 @@

# Upgrade pip with pip to fix angstwad/docker.ubuntu/pull/35 and docker-py/issues/525
# Install latest version when no specific release is set.
- name: Upgrade latest pip, setuptools, and docker-py with pip
- name: Upgrade latest pip, setuptools, docker-py and docker-compose with pip
pip:
name: "{{ item.name }}"
state: latest
with_items:
- { name: pip, version: "{{ pip_version_pip }}" }
- { name: setuptools, version: "{{ pip_version_setuptools }}" }
- { name: docker-py, version: "{{ pip_version_docker_py }}" }
- { name: docker-compose, version: "{{ pip_version_docker_compose }}" }
when: item.version=="latest"

# Install specific version when set in the variables
- name: Install specific pip, setuptools, and docker-py with pip
- name: Install specific pip, setuptools, docker-py and docker-compose with pip
pip:
name: "{{ item.name }}"
state: present
Expand All @@ -88,6 +89,7 @@
- { name: pip, version: "{{ pip_version_pip }}" }
- { name: setuptools, version: "{{ pip_version_setuptools }}" }
- { name: docker-py, version: "{{ pip_version_docker_py }}" }
- { name: docker-compose, version: "{{ pip_version_docker_compose }}" }
when: item.version!="latest"

- name: Check if /etc/updatedb.conf exists
Expand Down Expand Up @@ -127,3 +129,12 @@
name: docker.io
state: started
when: docker_pkg_name == 'docker.io'

# ATTENTION: this task can potentially create new users!
- name: Add users to the docker group
user:
name: "{{ item }}"
groups: docker
append: yes
with_items: docker_group_members
when: docker_group_members is defined
5 changes: 4 additions & 1 deletion tests/vagrant.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
# test file for docker.ubuntu role on vagrant
- hosts: all
remote_user: vagrant
sudo: true

vars:
docker_group_members: [ '{{ ansible_ssh_user }}' ]

roles:
- docker.ubuntu

0 comments on commit ec0e026

Please sign in to comment.