Skip to content

Commit

Permalink
Merge pull request #10 from charness/feature/upgrade_lts_kernel
Browse files Browse the repository at this point in the history
Generalize LTS kernel upgrades to 14.04 and to vagrant
  • Loading branch information
charness authored Jan 10, 2017
2 parents 0202ba9 + 5647f16 commit a85e163
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 24 deletions.
44 changes: 20 additions & 24 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,37 @@
fail: msg="Required variable \"docker_version\" is not defined."
when: docker_version is not defined

# https://docs.docker.com/installation/ubuntulinux/
- name: Install trusty kernel onto 12.04
# https://docs.docker.com/engine/installation/linux/ubuntulinux/#/prerequisites-by-ubuntu-version
# - 12.04: Docker requires the 3.13 kernel version.
# Ensure the trusty kernel is installed.
# - 14.04: Support aufs via the linux-image-extra-* kernel package.
# Achieve this with the xenial kernel, which depends on the
# corresponding extra package, to address issues with kernels
# before 3.19 at the same time.
# https://github.com/docker/docker/issues/21704#issuecomment-235365424
- name: Install HWE kernel on pre-16.04 LTS
apt:
pkg: "{{ item }}"
pkg: "{{ item.name }}"
state: latest
update_cache: yes
cache_valid_time: "{{ docker_role_apt_cache_valid_time }}"
with_items:
- linux-image-generic-lts-trusty
- linux-headers-generic-lts-trusty
- name: linux-image-generic-lts-trusty
version: "12.04"
- name: linux-headers-generic-lts-trusty
version: "12.04"
- name: linux-image-generic-lts-xenial
version: "14.04"
register: kernel_result
when: ansible_distribution_version == '12.04'
when: ansible_distribution_version == item.version

- name: Install latest kernel extras for Ubuntu 13.04+
- name: Install latest kernel extras for Ubuntu 13.04, 13.10
apt:
pkg: "linux-image-extra-{{ ansible_kernel }}"
state: "{{ kernel_pkg_state }}"
update_cache: yes
cache_valid_time: "{{ docker_role_apt_cache_valid_time }}"
when: ansible_distribution_version != '12.04'
when: ansible_distribution_version in ['13.04', '13.10']

# Fix for https://github.com/dotcloud/docker/issues/4568
- name: Install cgroup-lite for Ubuntu 13.10
Expand All @@ -41,22 +52,7 @@
register: cgroup_lite_result
when: ansible_distribution_version == '13.10'

- name: Reboot instance
command: /sbin/shutdown -r now
register: reboot_result
when: "(ansible_distribution_version == '12.04' and kernel_result|changed)
or (ansible_distribution_version == '13.10' and cgroup_lite_result|changed)"

- name: Wait for instance to come online
local_action:
module: wait_for
host: "{{ ansible_ssh_host|default(inventory_hostname) }}"
port: "{{ ansible_ssh_port|default(ssh_port) }}"
delay: 30
timeout: 600
state: started
when: "(ansible_distribution_version == '12.04' and reboot_result|changed)
or (ansible_distribution_version == '13.10' and cgroup_lite_result|changed)"
- include: reboot-and-wait.yml

# Newer versions of Docker no longer require apparmor, but it seems like a good thing to have.
- name: Install apparmor
Expand Down
27 changes: 27 additions & 0 deletions tasks/reboot-and-wait.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# reboot an Ubuntu machine if needed and wait for it to come back
- name: Detect vagrant instance
set_fact:
is_vagrant: "{{is_vagrant | default(ansible_ssh_user == 'vagrant')}}"

- name: Reboot instance
command: /sbin/shutdown -r now
args:
removes: /var/run/reboot-required
register: reboot_result

- name: Reload vagrant instance
local_action: command vagrant reload "{{inventory_hostname}}"
when: reboot_result|changed and is_vagrant
become: false

- name: Wait for instance to come online
local_action:
module: wait_for
host: "{{ ansible_ssh_host|default(inventory_hostname) }}"
port: "{{ ansible_ssh_port|default(ssh_port) }}"
delay: 30
timeout: 600
state: started
when: reboot_result|changed
become: false

0 comments on commit a85e163

Please sign in to comment.