Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cluster_kick.rb: adding chef-client-nonce invocation

  • Loading branch information...
commit 8d37c48b6f3775a8a37f9eb330b5b3f392088645 1 parent 82e35d7
@temujin9 temujin9 authored
Showing with 41 additions and 28 deletions.
  1. +3 −0  CHANGELOG.md
  2. +38 −28 lib/chef/knife/cluster_kick.rb
View
3  CHANGELOG.md
@@ -1,3 +1,6 @@
+# v4.7.6
+* adding chef-client-nonce invocation to knife cluster kick
+
# v4.7.5
* cluster_launch: correcting public_target to public_hostname
View
66 lib/chef/knife/cluster_kick.rb
@@ -63,35 +63,45 @@ def run
<%= ((config[:verbosity].to_i > 1) ? "set -v" : "") %>
-if sudo -p 'knife sudo password: ' service chef-client status ; then
-
- # running
- pid_file="<%= config[:pid_file] %>"
- log_file=<%= config[:log_file] %>
-
- declare tail_pid
-
- on_exit() {
- rm -f $pipe
- }
-
- trap "on_exit" EXIT ERR
-
- pipe=/tmp/pipe-$$
- mkfifo $pipe
-
- tail -Fn0 "$log_file" > $pipe &
-
- tail_pid=$!
-
- pid="$(sudo -p 'knife sudo password: ' cat $pid_file)"
- sudo -p 'knife sudo password: ' kill -USR1 "$pid"
- GOOD_RESULT='INFO: Report handlers complete\$'
- BAD_RESULT='ERROR: Sleeping for [0-9]+ seconds before trying again\$'
- sed -r -e "/$GOOD_RESULT/{q 0}" -e"/$BAD_RESULT/{q 1}" $pipe
+# New style server, using chef-client-nonce
+if [ -f /etc/init.d/chef-client-nonce ]; then
+ echo -e "****\n\nstarting chef-client-nonce service\n\n****\n"
+ sudo -p 'knife sudo password: ' service chef-client-nonce start
+# Old style server, using long-running chef-client
+elif [ -f /etc/init.d/chef-client ]; then
+ if sudo -p 'knife sudo password: ' service chef-client status ; then
+
+ # running
+ pid_file="<%= config[:pid_file] %>"
+ log_file=<%= config[:log_file] %>
+
+ declare tail_pid
+
+ on_exit() {
+ rm -f $pipe
+ }
+
+ trap "on_exit" EXIT ERR
+
+ pipe=/tmp/pipe-$$
+ mkfifo $pipe
+
+ tail -Fn0 "$log_file" > $pipe &
+
+ tail_pid=$!
+
+ pid="$(sudo -p 'knife sudo password: ' cat $pid_file)"
+ sudo -p 'knife sudo password: ' kill -USR1 "$pid"
+ GOOD_RESULT='INFO: Report handlers complete\$'
+ BAD_RESULT='ERROR: Sleeping for [0-9]+ seconds before trying again\$'
+ sed -r -e "/$GOOD_RESULT/{q 0}" -e"/$BAD_RESULT/{q 1}" $pipe
+ else
+ echo -e "****\n\nchef-client daemon not running, invoking chef-client directly\n\n****\n"
+ sudo -p 'knife sudo password: ' chef-client
+ fi
else
- echo -e "****\n\nchef-client daemon not running, invoking chef-client directly\n\n****\n"
- sudo -p 'knife sudo password: ' chef-client
+ echo -e "****\n\nNo chef-client found!\n\n****\n"
+ exit 1
fi
EOF
end

0 comments on commit 8d37c48

Please sign in to comment.
Something went wrong with that request. Please try again.