Skip to content

Commit

Permalink
Made kernel updates and reboots optional and disabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hryamzik committed May 10, 2015
1 parent e920274 commit 287772a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 62 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ install_kernel_extras: false
pip_version_pip: latest
pip_version_setuptools: latest
pip_version_docker_py: latest
# If this variable is set to true kernel updates and host restarts are permitted. Use with caution in production environments.
kernel_update_and_reboot_permitted: no
```

Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ install_kernel_extras: false
pip_version_pip: latest
pip_version_setuptools: latest
pip_version_docker_py: latest
# If this variable is set to true kernel updates and host restarts are permitted. Use with caution in production environments.
kernel_update_and_reboot_permitted: no
62 changes: 62 additions & 0 deletions tasks/kernel_check_and_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
- name: Install backported trusty kernel onto 12.04
apt:
pkg: "{{ item }}"
state: "{{ kernel_pkg_state }}"
update_cache: yes
cache_valid_time: 600
with_items:
- linux-image-generic-lts-trusty
- linux-headers-generic-lts-trusty
register: kernel_result
when: "ansible_distribution_version|version_compare(12.04, '=')"

- name: Install Xorg packages for backported kernels (very optional)
apt:
pkg: "{{ item }}"
state: installed
update_cache: yes
cache_valid_time: 600
with_items:
- xserver-xorg-lts-trusty
- libgl1-mesa-glx-lts-trusty
register: xorg_pkg_result
when: "install_xorg_pkgs and (kernel_result|changed or kernel_result|success)"

- name: Install latest kernel extras for Ubuntu 13.04+
apt:
pkg: "linux-image-extra-{{ ansible_kernel }}"
state: "{{ kernel_pkg_state }}"
update_cache: yes
cache_valid_time: 600
when: "ansible_distribution_version|version_compare(13.04, '=')
or ansible_distribution_version|version_compare(13.10, '=')
or install_kernel_extras"

# Fix for https://github.com/dotcloud/docker/issues/4568
- name: Install cgroup-lite for Ubuntu 13.10
apt:
pkg: cgroup-lite
state: "{{ cgroup_lite_pkg_state }}"
update_cache: yes
cache_valid_time: 600
register: cgroup_lite_result
when: "ansible_distribution_version|version_compare(13.10, '=')"

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

- name: Wait for instance to come online (10 minute timeout)
sudo: false
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|version_compare(12.04, '=') and reboot_result|changed)
or (ansible_distribution_version|version_compare(13.10, '=') and cgroup_lite_result|changed)"
65 changes: 3 additions & 62 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,9 @@
msg: "{{ ansible_distribution_version }} is not an acceptable version of Ubuntu for this role"
when: ansible_distribution_version|version_compare(12.04, '<') or ansible_distribution_version|version_compare(12.10, '=')

- name: Install backported trusty kernel onto 12.04
apt:
pkg: "{{ item }}"
state: "{{ kernel_pkg_state }}"
update_cache: yes
cache_valid_time: 600
with_items:
- linux-image-generic-lts-trusty
- linux-headers-generic-lts-trusty
register: kernel_result
when: "ansible_distribution_version|version_compare(12.04, '=')"

- name: Install Xorg packages for backported kernels (very optional)
apt:
pkg: "{{ item }}"
state: installed
update_cache: yes
cache_valid_time: 600
with_items:
- xserver-xorg-lts-trusty
- libgl1-mesa-glx-lts-trusty
register: xorg_pkg_result
when: "install_xorg_pkgs and (kernel_result|changed or kernel_result|success)"

- name: Install latest kernel extras for Ubuntu 13.04+
apt:
pkg: "linux-image-extra-{{ ansible_kernel }}"
state: "{{ kernel_pkg_state }}"
update_cache: yes
cache_valid_time: 600
when: "ansible_distribution_version|version_compare(13.04, '=')
or ansible_distribution_version|version_compare(13.10, '=')
or install_kernel_extras"

# Fix for https://github.com/dotcloud/docker/issues/4568
- name: Install cgroup-lite for Ubuntu 13.10
apt:
pkg: cgroup-lite
state: "{{ cgroup_lite_pkg_state }}"
update_cache: yes
cache_valid_time: 600
register: cgroup_lite_result
when: "ansible_distribution_version|version_compare(13.10, '=')"

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

- name: Wait for instance to come online (10 minute timeout)
sudo: false
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|version_compare(12.04, '=') and reboot_result|changed)
or (ansible_distribution_version|version_compare(13.10, '=') and cgroup_lite_result|changed)"
- name: update kernel
include: kernel_check_and_update.yml
when: kernel_update_and_reboot_permitted

- name: Add Docker repository key
apt_key:
Expand Down

0 comments on commit 287772a

Please sign in to comment.