Skip to content

Commit

Permalink
Merge pull request #9 from ninthnails/master
Browse files Browse the repository at this point in the history
Add support for Amazon, Fedora, Oracle Linux
  • Loading branch information
JasonGiedymin committed Feb 17, 2016
2 parents 9dc0ef2 + a55ebd7 commit 7515630
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.vagrant

.idea/
22 changes: 21 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Vagrant.configure("2") do |config|
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"
s.inline = "apt-get update -y; apt-get install python-software-properties; apt-add-repository -y ppa:ansible/ansible; apt-get update -y; apt-get install ansible -y"
s.privileged = true
end
end
Expand All @@ -37,4 +37,24 @@ Vagrant.configure("2") do |config|
end
end

# Fedora 23:
config.vm.define 'fedora23' do |c|
c.vm.network "private_network", ip: "192.168.100.6"
c.vm.box = "fedora/23-cloud-base"
c.vm.provision "shell" do |s|
s.inline = "dnf install -y epel-release; dnf install -y ansible python-dnf"
s.privileged = true
end
end

# Oracle Linux 7.2:
config.vm.define 'oraclelinux72' do |c|
c.vm.network "private_network", ip: "192.168.100.7"
c.vm.box = "box-cutter/ol72"
c.vm.provision "shell" do |s|
s.inline = "yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm; yum install -y ansible"
s.privileged = true
end
end

end
18 changes: 16 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
---
# RedHat: Docker yum repository URL
docker_yum_repo: "https://yum.dockerproject.org/repo/main/{{ ansible_distribution | lower }}/{{ os_version_major }}"
# Empty version so latest is picked by default. See below.
# Provide value to install a specific version. For example:
# for Debian system, 1.9.0-1
# for RedHat system, 1.10
docker_version:

# Debian:
docker_apt_package: "lxc-docker{{ '=' + docker_version if docker_version else '' }}"

# RedHat:
docker_yum_repo_url: "https://yum.dockerproject.org/repo/main"
docker_yum_repo: "{{ docker_yum_repo_url }}/{{ docker_yum_repo_uris[ansible_distribution] }}"
docker_yum_repo_gpg: 'https://yum.dockerproject.org/gpg'
docker_yum_package: "docker-engine{{ '-' + docker_version if docker_version else '' }}"

# Prior to 1.9, starting Docker engine as daemon use flag '-d' was used, now it's 'daemon' argument
docker_daemon_opts: "{{ 'daemon' if docker_version == '' or docker_version | version_compare('1.9', '>=') else '-d' }}{{ ' -H fd://' if ansible_os_family == 'RedHat' else ''}}"

docker_opts: ''
docker_create_group: true
Expand Down
18 changes: 15 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ galaxy_info:
description: Ansible Docker Playbook Role
company: http://jasongiedymin.com
license: Apache 2
min_ansible_version: 1.2
min_ansible_version: 1.9
#
# Below are all platforms currently available. Just uncomment
# the ones that apply to your role. If you don't see your
# platform on this list, let us know and we'll get it added!
#
platforms:
- name: Amazon
versions:
- 2015.03
- name: CentOS
versions:
- 7
#- name: EL
# versions:
# - all
Expand All @@ -20,14 +26,20 @@ galaxy_info:
# versions:
# - all
# - any
#- name: Fedora
# versions:
- name: Fedora
versions:
# - all
# - 16
# - 17
# - 18
# - 19
# - 20
# - 21
# - 22
- 23
- name: OracleLinux
versions:
- 7.2
#- name: opensuse
# versions:
# - all
Expand Down
2 changes: 1 addition & 1 deletion tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
apt_repository: repo='deb {{ docker_repo }} docker main' state=present

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

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

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

- name: (yum) Install SELinux python bindings
yum: name=libselinux-python state=present
when: ansible_selinux is defined and ansible_pkg_mgr == 'yum'

- name: Install Docker Engine
yum: name=docker-engine state=present
- name: (yum) Install Docker Engine
yum: name={{ docker_yum_package }} state=present
when: ansible_pkg_mgr == 'yum'

- name: (dnf) Install SELinux python bindings
dnf: name=libselinux-python state=present
when: ansible_selinux is defined and ansible_pkg_mgr == 'dnf'

- name: (dnf) Install Docker Engine
dnf: name=docker-engine state=present
when: ansible_pkg_mgr == 'dnf'

2 changes: 1 addition & 1 deletion templates/docker-init.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ respawn

script
[ ! -f /etc/default/docker ] || . /etc/default/docker
/usr/bin/docker -d $DOCKER_OPTS
/usr/bin/docker {{ docker_daemon_opts }} $DOCKER_OPTS
end script
2 changes: 1 addition & 1 deletion templates/docker-service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Requires=docker.socket
[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/docker
ExecStart=/usr/bin/docker -d -H fd:// $OPTIONS
ExecStart=/usr/bin/docker {{ docker_daemon_opts }} $OPTIONS
{% if docker_service_start_timeout != '' %}
TimeoutStartSec={{ docker_service_start_timeout }}
{% endif %}
Expand Down
15 changes: 14 additions & 1 deletion vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
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') }}"
os_version_major: "
{%- if ansible_distribution_major_version is defined -%}
{{- ansible_distribution_major_version -}}
{%- elif '.' in os_version %}
{{- os_version[:os_version.index('.')] -}}
{%- else -%}
{{- os_version -}}
{%- endif -%}
"
docker_yum_repo_uris:
Amazon: "centos/{{ 6 if '2014' in os_version or ('2015' in os_version and os_version[os_version.index('.'):] | int <= 3) else 7 }}"
CentOS: "centos/{{ os_version_major }}"
Fedora: "fedora/{{ os_version_major }}"
OracleLinux: "oraclelinux/{{ os_version_major }}"

2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker_playbook_version: "0.1.3"
docker_playbook_version: "0.1.5"

0 comments on commit 7515630

Please sign in to comment.