Docker role for Debian GNU/Linux

This commit is contained in:
Difrex 2016-02-10 11:06:46 +03:00
commit 787eaa52fc
7 changed files with 81 additions and 0 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# Ansible roles

5
playbooks/docker.yml Normal file
View File

@ -0,0 +1,5 @@
- hosts: docker
sudo: True
gather_facts: True
roles:
- docker

View File

@ -0,0 +1,3 @@
---
- name: docker - start and enable
service: name=docker enabled=yes state=restarted

View 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:

View 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

View 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"

View File

@ -0,0 +1,4 @@
---
- include: grub.yml
- include: docker.yml