Docker role for Debian GNU/Linux
This commit is contained in:
commit
787eaa52fc
5
playbooks/docker.yml
Normal file
5
playbooks/docker.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
- hosts: docker
|
||||||
|
sudo: True
|
||||||
|
gather_facts: True
|
||||||
|
roles:
|
||||||
|
- docker
|
3
roles/docker/handlers/main.yml
Normal file
3
roles/docker/handlers/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
- name: docker - start and enable
|
||||||
|
service: name=docker enabled=yes state=restarted
|
13
roles/docker/meta/main.yml
Normal file
13
roles/docker/meta/main.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: Denis Ryabyy <vv1r0x@gmail.com>, Denis a.k.a Difrex Zheleztsov <difrex.punk@gmail.com>
|
||||||
|
description: Ansible role for installing docker for Debian.
|
||||||
|
min_ansible_version: 1.4
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- wheezy
|
||||||
|
- jessie
|
||||||
|
categories:
|
||||||
|
- system
|
||||||
|
dependencies:
|
28
roles/docker/tasks/docker.yml
Normal file
28
roles/docker/tasks/docker.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
- name: Install docker deps
|
||||||
|
apt: pkg={{item}}
|
||||||
|
with_items:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
|
- bridge-utils
|
||||||
|
|
||||||
|
- name: Remove old apt keys
|
||||||
|
apt_key: state=absent id={{item}}
|
||||||
|
with_items:
|
||||||
|
- D8576A8BA88D21E9
|
||||||
|
|
||||||
|
- name: Add docker apt key
|
||||||
|
apt_key: keyserver=hkp://pgp.mit.edu id=58118E89F3A912897C070ADBF76221572C52609D
|
||||||
|
|
||||||
|
- name: Remove old docker repos
|
||||||
|
apt_repository: repo='deb https://get.docker.com/ubuntu docker main' state=absent
|
||||||
|
|
||||||
|
- name: add docker repo
|
||||||
|
apt_repository: repo='deb https://apt.dockerproject.org/repo {{ansible_distribution | lower}}-{{ansible_distribution_release}} main' update_cache=yes
|
||||||
|
|
||||||
|
- name: remove old docker package
|
||||||
|
apt: pkg=lxc-docker state=absent
|
||||||
|
|
||||||
|
- name: install docker
|
||||||
|
apt: pkg=docker-engine
|
||||||
|
notify: docker - start and enable
|
27
roles/docker/tasks/grub.yml
Normal file
27
roles/docker/tasks/grub.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Check if cgroup memory and swapaccount in kernel
|
||||||
|
shell: grep GRUB_CMDLINE_LINUX_DEFAULT /etc/default/grub | grep -c "cgroup_enable=memory swapaccount=1"
|
||||||
|
register: cgroup_status
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Enable cgroup memory and swapaccount
|
||||||
|
lineinfile: dest="/etc/default/grub" regexp='GRUB_CMDLINE_LINUX_DEFAULT="(.*)"' line='GRUB_CMDLINE_LINUX_DEFAULT="\1 cgroup_enable=memory swapaccount=1"' backrefs=yes
|
||||||
|
when: cgroup_status.stdout == "0"
|
||||||
|
|
||||||
|
- name: update-grub
|
||||||
|
shell: update-grub2
|
||||||
|
when: cgroup_status.stdout == "0"
|
||||||
|
|
||||||
|
- name: reboot if we need it
|
||||||
|
shell: sleep 2 && shutdown -r now "Ansible updates triggered"
|
||||||
|
async: 1
|
||||||
|
poll: 0
|
||||||
|
ignore_errors: true
|
||||||
|
when: cgroup_status.stdout == "0"
|
||||||
|
|
||||||
|
- name: waiting for server to come back
|
||||||
|
local_action: wait_for host={{ansible_fqdn}} state=started timeout=600 delay=15
|
||||||
|
sudo: false
|
||||||
|
when: cgroup_status.stdout == "0"
|
||||||
|
|
4
roles/docker/tasks/main.yml
Normal file
4
roles/docker/tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- include: grub.yml
|
||||||
|
|
||||||
|
- include: docker.yml
|
Loading…
Reference in New Issue
Block a user