Skip to content

Commit

Permalink
Merge pull request #7 from ninthnails/master
Browse files Browse the repository at this point in the history
yum repo URL defaults and apt module
  • Loading branch information
ninthnails committed Dec 6, 2015
2 parents b291de4 + 13923ac commit a57e7f8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 23 deletions.
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
ansible-docker
ansible-docker - Ansible Playbook for Docker
==============

Docker Playbook for Ansible
## Overview

This playbook will install Docker.
The `ansible-docker` role supports the installation and configuration of Docker Engine. It supports Ubuntu and RedHat/Centos.

## Requirements

No requirement.


## Development

Changes can be tested by using Vagrant machines configure for this role, see `Vagrantfile`.

```bash
cd ansible-docker/
vagrant up {travis|ubuntu|centos7}
vagrant ssh {travis|ubuntu|centos7}

$ cd roles/ansible-docker/
$ ansible-playbook -i ci/inventory ci/playbook.yml --connection=local --sudo

PLAY [localhost] **************************************************************

GATHERING FACTS ***************************************************************
ok: [localhost]

...

TASK: [command docker run hello-world] ****************************************
changed: [localhost]

PLAY RECAP ********************************************************************
localhost : ok=12 changed=1 unreachable=0 failed=0
```

Support open source!

6 changes: 4 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
docker_playbook_version: "0.1.2"
# RedHat: Docker yum repository URL
docker_yum_repo: "https://yum.dockerproject.org/repo/main/{{ ansible_distribution | lower }}/{{ os_version_major }}"
docker_yum_repo_gpg: 'https://yum.dockerproject.org/gpg'

docker_opts: ''
docker_create_group: true
Expand All @@ -12,7 +14,7 @@ docker_service_start_timeout: '' # use system default value
# - uncomment `docker_opts` or provide it as a override
#
# Note:
# By setting `-H` opt for docker, it will no longer be listenting
# By setting `-H` opt for docker, it will no longer be listening
# on the socket. You cannot have both. You must choose socket `-d`
# or tcp `-H`.
#
Expand Down
23 changes: 7 additions & 16 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
- name: Get uname
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}}

- name: Update
command: apt-get update
apt_key: id={{docker_repo_key}} keyserver=keyserver.ubuntu.com state=present

- name: Install https apt transport package
command: apt-get install -y apt-transport-https
apt: pkg=apt-transport-https state=present update_cache=yes

- name: Add docker repo
command: sudo sh -c "echo deb {{docker_repo}} docker main > /etc/apt/sources.list.d/docker.list"
apt_repository: repo='deb {{ docker_repo }} docker main' state=present

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

# 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 All @@ -29,6 +20,6 @@
command: ufw reload
when: docker_listen_tcp == True

- name: Allow incomming tcp traffic on {{docker_listen_port}}
- name: Allow incoming tcp traffic on {{docker_listen_port}}
command: ufw allow {{docker_listen_port}}/tcp
when: docker_listen_tcp == True
2 changes: 1 addition & 1 deletion templates/docker-repo.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name=Docker Repository
baseurl={{ docker_yum_repo }}
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
gpgkey={{ docker_yum_repo_gpg }}
1 change: 0 additions & 1 deletion vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
os_version: "{{ ansible_lsb.release if ansible_lsb is defined else ansible_distribution_version }}"
os_version_major: "{{ os_version | regex_replace('^([0-9]+)[^0-9]*.*', '\\\\1') }}"

docker_yum_repo: "https://yum.dockerproject.org/repo/main/{{ ansible_distribution | lower }}/{{ os_version_major }}"
1 change: 1 addition & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker_playbook_version: "0.1.3"

0 comments on commit a57e7f8

Please sign in to comment.