-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
look for scheduled reboot instead of pending
I misunderstood what the built-in `reboot_pending?` function does. It looks to determine if a host needs rebooted after a package update has been installed and does not strictly mean that a reboot is scheduled via `shutdown`, which is what I really wanted to test for. dbus systems support fetching whether a reboot is scheduled. I've effectively only whitelisted this for Ubuntu systems because that's all I really presently care about but should be able to be extended to other systems easily if the desire is there.
- Loading branch information
Matt Kulka
committed
Nov 12, 2019
1 parent
6a8f202
commit 100ccf3
Showing
6 changed files
with
23 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
default['kill_switch']['engage'] = false | ||
default['kill_switch']['normal_exit'] = false | ||
default['kill_switch']['touch_dir'] = case node['os'] | ||
when 'windows' | ||
'C:' | ||
end | ||
default['kill_switch']['touch_file'] = File.join(node['kill_switch']['touch_dir'].to_s, '.kill_chef') | ||
default['kill_switch']['when_reboot_pending'] = true | ||
default['kill_switch']['when_reboot_scheduled'] = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
def reboot_scheduled? | ||
case node['platform'] | ||
when 'ubuntu' | ||
if node['platform_version'].to_i >= 16 | ||
cmd = Mixlib::ShellOut.new('busctl get-property org.freedesktop.login1 /org/freedesktop/login1 ' \ | ||
'org.freedesktop.login1.Manager ScheduledShutdown') | ||
cmd.run_command | ||
return cmd.exitstatus == 0 && (cmd.stdout.include?('"poweroff"') || cmd.stdout.include?('"reboot"')) | ||
end | ||
end | ||
false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters