Skip to content

Commit

Permalink
Trust packages for whether reboot is necessary
Browse files Browse the repository at this point in the history
Installing a kernel package on Ubuntu creates a
/var/run/reboot-required file. Key off its existence instead of trying
to figure out ourselves whether to reboot.

The `removes' argument to `command' handles conditioning the reboot on
whether the file exists.

For a vagrant instance, fire a `vagrant reload' after rebooting from
on the machine so we still get the setup `vagrant up' does.
  • Loading branch information
Dave Charness committed Dec 16, 2016
1 parent 8e3d335 commit b90e21c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
4 changes: 0 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
register: cgroup_lite_result
when: ansible_distribution_version == '13.10'

- name: Is reboot necessary?
set_fact:
reboot_needed: "{{(kernel_result or cgroup_lite_result or {'changed': False}) | changed}}"

- include: reboot-and-wait.yml

# Newer versions of Docker no longer require apparmor, but it seems like a good thing to have.
Expand Down
13 changes: 4 additions & 9 deletions tasks/reboot-and-wait.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@

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

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

- name: Wait for instance to come online
Expand All @@ -29,4 +25,3 @@
state: started
when: reboot_result|changed
become: false

0 comments on commit b90e21c

Please sign in to comment.