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

Use a template to generate docker.list #3

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9575f45
Use a template to generate docker.list
ludovicc Aug 17, 2015
4c1b443
Quote DOCKER_OPTS
ludovicc Aug 19, 2015
af49150
Add Vagrantfile and tests
ludovicc Aug 19, 2015
56b29fb
Attempt to please Travis CI
ludovicc Aug 19, 2015
c931eb2
Use apt-key
Sep 6, 2015
bc45209
More efficient installation of Docker
ludovicc Oct 7, 2015
b99008f
Fix repo var
ludovicc Oct 7, 2015
e987995
Fix repo var take 2
ludovicc Oct 7, 2015
596f7ee
Fix runlevel to start Docker on startup
ludovicc Oct 12, 2015
f523b9c
Configure systemd
ludovicc Oct 26, 2015
b46c9e1
Use proper name for new package
Oct 26, 2015
028690f
Mark tasks without side effects
Oct 26, 2015
da1c96b
Typo
ludovicc Oct 27, 2015
60f56c1
Add missing check
ludovicc Oct 28, 2015
15937cb
Fix version of Docker
ludovicc Nov 4, 2015
57cf208
Merge remote-tracking branch 'upstream/master'
ludovicc Nov 23, 2015
44ed971
Use init script from Docker 1.9.1
ludovicc Nov 23, 2015
b9ee360
Avoid spurious detection of systemd on Ubuntu 14.04.3
ludovicc Nov 26, 2015
5c98925
Align start trigger with the latest Docker engine
ludovicc Feb 4, 2016
85a841a
Merge remote-tracking branch 'upstream/master' into upstream
ludovicc Feb 15, 2016
7505e3b
Merge branch 'master' of github.com:ludovicc/ansible-docker
ludovicc Feb 15, 2016
498fc8e
Docker 1.10 now uses a daemon command instead of -d flag
ludovicc Feb 19, 2016
3737bf1
Don't always update apt cache
Feb 28, 2016
58218fe
Fix configuration under systemd
ludovicc Nov 14, 2016
9f925de
Cleanup deprecation warning
ludovicc Nov 16, 2016
95edfc8
New naming convension for Docker versions
ludovicc Dec 19, 2016
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vagrant/

51 changes: 51 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.ssh.forward_agent = true
config.vm.synced_folder Dir.getwd, "/home/vagrant/roles/ansible-docker", nfs: true

# ubuntu 12.04 that Travis CI is using
config.vm.define 'travis', primary: true do |c|
c.vm.network "private_network", ip: "192.168.100.2"
c.vm.box = "precise-server-cloudimg-amd64-vagrant-disk1"
c.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
c.vm.provision "shell" do |s|
s.inline = "apt-get update -y; apt-get install python-software-properties; add-apt-repository ppa:rquillo/ansible; apt-get update -y; apt-get install ansible -y; cd /home/vagrant/roles/ansible-docker/tests; ansible-playbook -i inventory playbook.yml"
s.privileged = true
end
end

# ubuntu 14.04
config.vm.define 'ubuntu', primary: true do |c|
c.vm.network "private_network", ip: "192.168.100.3"
c.vm.box = "trusty-server-cloudimg-amd64-vagrant-disk1"
c.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
c.vm.provision "shell" do |s|
s.inline = "apt-get update -y; apt-get install -y software-properties-common; apt-add-repository ppa:ansible/ansible; apt-get update -y; apt-get install -y ansible; cd /home/vagrant/roles/ansible-docker/tests; ansible-playbook -i inventory playbook.yml"
s.privileged = true
end
end

# centos 6:
config.vm.define 'centos' do |c|
c.vm.network "private_network", ip: "192.168.100.4"
c.vm.box = "centos65-x86_64-20140116"
c.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
c.vm.provision "shell" do |s|
s.inline = "yum update gmp; yum install ansible -y; cd /home/vagrant/roles/ansible-docker/tests; ansible-playbook -i inventory playbook.yml"
s.privileged = true
end
end

# centos 7:
config.vm.define 'centos7' do |c|
c.vm.network "private_network", ip: "192.168.100.5"
c.vm.box = "centos/7"
c.vm.provision "shell" do |s|
s.inline = "yum install -y epel-release; yum install -y ansible; cd /home/vagrant/roles/ansible-docker/tests; ansible-playbook -i inventory playbook.yml"
s.privileged = true
end
end

end
8 changes: 6 additions & 2 deletions ci/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
connection: local
sudo: yes
gather_facts: false

tasks:
- command: docker run hello-world
- name: Wait for Docker to be up
wait_for: path=/var/run/docker.sock state=started delay=3 timeout=5

- name: Test that Docker can run hello-world
command: docker run --rm hello-world
register: status
failed_when: status.rc != 0
25 changes: 15 additions & 10 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@
command: uname -r
register: os_uname

# would rather have used ansible apt-key...
- name: Add specific key
command: apt-key adv --keyserver keyserver.ubuntu.com --recv-keys {{docker_repo_key}}
apt_key:
id: "{{docker_repo_key}}"
keyserver: keyserver.ubuntu.com
state: present

- name: Update
command: apt-get update
- name: Add docker repo
apt_repository:
repo: "deb {{ docker_repo }} docker main"
state: present

- name: Install https apt transport package
command: apt-get install -y apt-transport-https

- name: Add docker repo
command: sudo sh -c "echo deb {{docker_repo}} docker main > /etc/apt/sources.list.d/docker.list"
apt: pkg=apt-transport-https state=present update_cache=yes cache_valid_time=600
Copy link
Contributor

Choose a reason for hiding this comment

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

This action and the next one can be merge together.


- name: Install lxc-docker package
apt: pkg={{item}} state=present update_cache=yes
apt:
pkg: "{{item}}"
state: present
update_cache: yes
cache_valid_time: 600
with_items:
- lxc-docker

# consider seperate role here
# consider separate role here
- name: Change ufw forward policy to ACCEPT
command: sed -i 's/DEFAULT_FORWARD_POLICY="DROP"/DEFAULT_FORWARD_POLICY="ACCEPT"/g' /etc/default/ufw
when: docker_listen_tcp == True
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
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
when: docker_create_group
tags:
- config

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

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

Expand Down
3 changes: 2 additions & 1 deletion templates/docker-defaults.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated by Ansible for {{ansible_fqdn}}

DOCKER_OPTS={{docker_opts}}
DOCKER_OPTS="{{docker_opts}}"

3 changes: 1 addition & 2 deletions templates/docker-init.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Generated by Ansible for {{ansible_fqdn}}
description "Docker daemon"

start on filesystem and started lxc-net
stop on runlevel [!2345]
start on stopped rc RUNLEVEL=[2345]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand what that change does, can you please explain ?


respawn

Expand Down
2 changes: 2 additions & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[local]
Copy link
Contributor

Choose a reason for hiding this comment

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

There is already an ci/ folder for testing, why adding this one or not removing the other ?

localhost
14 changes: 14 additions & 0 deletions tests/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---

- hosts: localhost
connection: local
sudo: yes

tasks:
- name: Wait for Docker to be up
wait_for: path=/var/run/docker.sock state=started delay=3 timeout=5

- name: Test that Docker can run hello-world
command: docker run --rm hello-world
register: status
failed_when: status.rc != 0
14 changes: 14 additions & 0 deletions tests/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
#
# Test Playbook
#

- hosts: localhost
connection: local
sudo: yes

roles:
- {role: ../../}

- include: main.yml