File tree Expand file tree Collapse file tree 6 files changed +23
-7
lines changed Expand file tree Collapse file tree 6 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,9 @@ There is some monkey-patching that needs to happen to have the option of a clean
36
36
<td><tt>C:\\.kill_chef</tt> on Windows, <tt>/.kill_chef</tt> on Linux</td>
37
37
</tr >
38
38
<tr >
39
- <td><tt>['kill_switch']['when_reboot_pending ']</tt></td>
39
+ <td><tt>['kill_switch']['when_reboot_scheduled ']</tt></td>
40
40
<td>Bool</td>
41
- <td>Engage kill switch if there is a pending reboot</td>
41
+ <td>Engage kill switch if there is a scheduled reboot (only supported on Ubuntu 16+ presently) </td>
42
42
<td><tt>true</tt></td>
43
43
</tr >
44
44
</table >
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
1
3
default [ 'kill_switch' ] [ 'engage' ] = false
2
4
default [ 'kill_switch' ] [ 'normal_exit' ] = false
3
5
default [ 'kill_switch' ] [ 'touch_dir' ] = case node [ 'os' ]
4
6
when 'windows'
5
7
'C:'
6
8
end
7
9
default [ 'kill_switch' ] [ 'touch_file' ] = File . join ( node [ 'kill_switch' ] [ 'touch_dir' ] . to_s , '.kill_chef' )
8
- default [ 'kill_switch' ] [ 'when_reboot_pending ' ] = true
10
+ default [ 'kill_switch' ] [ 'when_reboot_scheduled ' ] = true
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ def reboot_scheduled?
4
+ case node [ 'platform' ]
5
+ when 'ubuntu'
6
+ if node [ 'platform_version' ] . to_i >= 16
7
+ cmd = Mixlib ::ShellOut . new ( 'busctl get-property org.freedesktop.login1 /org/freedesktop/login1 ' \
8
+ 'org.freedesktop.login1.Manager ScheduledShutdown' )
9
+ cmd . run_command
10
+ return cmd . exitstatus == 0 && ( cmd . stdout . include? ( '"poweroff"' ) || cmd . stdout . include? ( '"reboot"' ) )
11
+ end
12
+ end
13
+ false
14
+ end
Original file line number Diff line number Diff line change 4
4
license 'MIT'
5
5
description 'Kill switch to prevent Chef runs from occuring'
6
6
long_description IO . read ( File . join ( File . dirname ( __FILE__ ) , 'README.md' ) )
7
- version '1.1.0 '
7
+ version '1.1.1 '
8
8
chef_version '>= 12.1' if respond_to? ( :chef_version )
9
9
10
10
%w[ ubuntu debian fedora centos redhat oracle scientific amazon freebsd openbsd mac_os_x solaris2 opensuse opensuseleap
Original file line number Diff line number Diff line change 10
10
reason = "node attribute ['kill_switch']['engage']"
11
11
elsif File . exist? ( node [ 'kill_switch' ] [ 'touch_file' ] )
12
12
reason = "touch file #{ node [ 'kill_switch' ] [ 'touch_file' ] } "
13
- elsif node [ 'kill_switch' ] [ 'when_reboot_pending ' ] && reboot_pending ?
14
- reason = 'reboot pending '
13
+ elsif node [ 'kill_switch' ] [ 'when_reboot_scheduled ' ] && reboot_scheduled ?
14
+ reason = 'reboot scheduled '
15
15
else
16
16
return
17
17
end
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ class FakeException < RuntimeError; end
67
67
chef_run . node . normal [ 'kill_switch' ] [ 'engage' ] = false
68
68
allow ( File ) . to receive ( :exist? ) . and_call_original
69
69
allow ( File ) . to receive ( :exist? ) . with ( '/.kill_chef' ) . and_return ( false )
70
- allow_any_instance_of ( Chef ::Recipe ) . to receive ( :reboot_pending ? ) . and_return ( true )
70
+ allow_any_instance_of ( Chef ::Recipe ) . to receive ( :reboot_scheduled ? ) . and_return ( true )
71
71
end
72
72
73
73
it 'exits noisily' do
You can’t perform that action at this time.
0 commit comments