Skip to content

Instantly share code, notes, and snippets.

@lorentzca
Last active October 8, 2015 02:26
Show Gist options
  • Save lorentzca/5bd07ea8fd19f8af70c6 to your computer and use it in GitHub Desktop.
Save lorentzca/5bd07ea8fd19f8af70c6 to your computer and use it in GitHub Desktop.
複数のホストにcookするやつ
#!/usr/bin/env ruby
require 'thor'
class CookMan < Thor
desc "prepare", "Prepare to one or more hosts"
option :hostname, :required => true, :aliases => :h, :type => :array
def prepare
options[:hostname].each do |h|
system "bundle exec knife solo prepare #{h}"
end
end
desc "cook", "Cook to one or more hosts"
option :hostname, :required => true, :aliases => :h, :type => :array
def cook
options[:hostname].each do |h|
system "bundle exec knife solo cook #{h}"
end
end
desc "bootstrap", "Bootstrap to one or more hosts"
option :hostname, :required => true, :aliases => :h, :type => :array
def bootstrap
options[:hostname].each do |h|
system "bundle exec knife solo bootstrap #{h}"
end
end
end
CookMan.start(ARGV)
@lorentzca
Copy link
Author

準備

$ gem install thor

うさげ

$ cookman
Commands:
  cookman bootstrap h, --hostname=one two three  # Bootstrap to one or more hosts
  cookman cook h, --hostname=one two three       # Cook to one or more hosts
  cookman help [COMMAND]                         # Describe available commands or one specific co...
  cookman prepare h, --hostname=one two three    # Prepare to one or more hosts

とど

  • ドライラン出来るようにする

$ echo hogehoge.hoge piyopiyo.piyo | xargs -n 1 bundle exec knife solo cookでよいのでは?

  • すみません thor使ってみたかったんです;;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment