Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to use the docker-engine #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
---
- name: Add specific key
apt_key: id={{docker_repo_key}} keyserver=keyserver.ubuntu.com state=present

- name: Install https apt transport package
apt: pkg=apt-transport-https state=present update_cache=yes
- name: Add specific key
apt_key: keyserver={{docker_repo_key_server}} id={{docker_repo_key}}

- name: Add docker repo
apt_repository: repo='deb {{ docker_repo }} docker main' state=present
apt_repository: repo='deb {{docker_repo}} ubuntu-{{ansible_distribution_release}} main' state=present
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem I see here is you only expect to be installed on Ubuntu system by using ubuntu-{{ansible_distribution_release}}. For vanilla Debian system, it's debian-{{ansible_distribution_release}}.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for the previous comment, {{ ansible_distribution | lower }}-{{ ansible_distribution_release }} is OK instead , isnt it? just FYI my patchset is ceaaf07


- name: Update apt
apt: update_cache=yes

- name: Purge the old repo if it exists
apt: name=lxc-docker* purge=yes
ignore_errors: yes

- name: Verify that apt is pulling from the right repository
command: apt-cache policy docker-engine

- name: Install the recommended package
apt: name=linux-image-extra-{{ansible_kernel}} state=present
when: docker_install_recommended_package

- name: Install lxc-docker package
apt: pkg=lxc-docker state=present update_cache=yes
- name: Install Docker
apt: name=docker-engine state=present update_cache=yes

# consider separate role here
- name: Change ufw forward policy to ACCEPT
Expand Down
2 changes: 1 addition & 1 deletion tasks/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

- name: Install Docker Repository
template: src=docker-repo.j2 dest=/etc/yum.repos.d/docker.repo

- name: Install Docker Engine
yum: name=docker-engine state=present

2 changes: 1 addition & 1 deletion tasks/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
when: systemd_check.stat.exists == true
notify:
- Restart Docker

- name: Docker systemd file
template: src=docker-service.j2 dest=/lib/systemd/system/docker.service backup=yes
when: systemd_check.stat.exists == true
Expand Down
12 changes: 9 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
when: docker_create_group
tags:
- config


- name: Create the docker group and add your user
command: usermod -aG docker {{ansible_ssh_user}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use proper group module for creating group. Can't avoid command for "adding" user to group though.
Use a variable for the user, not always the user making the connection that needs to be added to the group.
Group name can also be a variable if someone wants to use a different one.

when: docker_create_group
tags:
- config

- include: Debian.yml
when: ansible_os_family == "Debian"

- include: RedHat.yml
when: ansible_os_family == "RedHat"

- include: init.yml
# - include: init.yml
6 changes: 4 additions & 2 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# replace with gist variant
docker_repo_key: "36A1D7869245C8950F966E92D8576A8BA88D21E9"
docker_repo: "https://get.docker.io/ubuntu"
docker_repo_key_server: "hkp://p80.pool.sks-keyservers.net:80"
docker_repo_key: "58118E89F3A912897C070ADBF76221572C52609D"
docker_repo: "https://apt.dockerproject.org/repo"
docker_install_recommended_package: True