This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to commander, add default node name support
- Loading branch information
Vasily Mikhaylichenko
committed
Feb 27, 2013
1 parent
d7bcf23
commit 11179c8
Showing
7 changed files
with
74 additions
and
38 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,51 +1,78 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'rubygems' | ||
require 'optitron' | ||
require 'gli' | ||
|
||
$LOAD_PATH << File.expand_path("../..", __FILE__) | ||
require 'lib/gusteau' | ||
|
||
class Gusteau::CLI < Optitron::CLI | ||
include GLI::App | ||
|
||
class_opt 'bootstrap', 'Install chef-solo' | ||
class_opt 'format', 'Output format to use', :short_name => 'F', :type => :string | ||
class_opt 'log_level', 'Set the log level', :in => %w{debug info warn error fatal} | ||
class_opt 'why-run', 'Enable whyrun mode', :short_name => 'W' | ||
program_desc Gusteau::DESCRIPTION | ||
version Gusteau::VERSION | ||
sort_help :manually | ||
|
||
desc 'Fully provision a node' | ||
def provision(node_name) | ||
node(node_name).provision(params) | ||
end | ||
default_node = ENV['GUSTEAU_NODE'] || 'vagrant' | ||
|
||
desc 'Run recipe(s)' | ||
def run(node_name, *recipe) | ||
node(node_name).run(params, recipe) | ||
end | ||
desc 'Node to use' | ||
flag [:n, :node], :arg_name => 'node', :default_value => default_node | ||
|
||
desc 'Install chef-solo' | ||
switch [:b, :bootstrap], :negatable => false | ||
|
||
desc 'Output format to use' | ||
flag ['F', 'format'], :arg_name => 'format' | ||
|
||
desc 'SSH into a node' | ||
def ssh(node_name) | ||
node(node_name).ssh | ||
desc 'Set the log level' | ||
flag ['l', 'log_level'], :arg_name => 'log_level' | ||
|
||
desc 'Enable whyrun node' | ||
switch ['W', 'why-run'], :negatable => false | ||
|
||
on_error {} | ||
|
||
desc 'Fully provision a node' | ||
command 'provision' do |c| | ||
c.action do |global, options, args| | ||
node(global[:node]).provision(options.merge global) | ||
end | ||
end | ||
|
||
desc 'Generate an example project (a bureau)' | ||
def generate(bureau_name) | ||
Gusteau::Bureau.new(bureau_name) | ||
desc 'Run recipe(s)' | ||
command 'run' do |c| | ||
c.arg_name 'recipe', :multiple | ||
|
||
c.action do |global, options, args| | ||
node(global[:node]).run(options.merge global, args) | ||
end | ||
end | ||
|
||
private | ||
desc 'SSH into a node' | ||
command 'ssh' do |c| | ||
c.action do |global, options, args| | ||
node(global[:node]).ssh | ||
end | ||
end | ||
|
||
def node(node_name) | ||
unless node_path = Dir.glob("./nodes/**/#{node_name}.yml")[0] | ||
abort "Node '#{node_name}' is unknown. Known nodes are #{nodes_list.join(', ')}." | ||
end | ||
Gusteau::Node.new(node_path) | ||
end | ||
|
||
def nodes_list | ||
Dir.glob("./nodes/**/*.yml").map { |f| File.basename(f, '.*') } | ||
desc 'Generate an example project (a bureau)' | ||
command 'generate' do |c| | ||
c.action do |global, options, args| | ||
Gusteau::Bureau.new(args[0]) | ||
end | ||
end | ||
|
||
def node(node_name) | ||
unless node_path = Dir.glob("./nodes/**/#{node_name}.yml")[0] | ||
abort "Node '#{node_name}' is unknown. Known nodes are #{nodes_list.join(', ')}." | ||
end | ||
Gusteau::Node.new(node_path) | ||
end | ||
|
||
def nodes_list | ||
Dir.glob("./nodes/**/*.yml").map { |f| File.basename(f, '.*') } | ||
end | ||
|
||
Gusteau::CLI.dispatch | ||
exit run(ARGV) |
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
module Gusteau | ||
require 'gusteau/node' | ||
require 'gusteau/bureau' | ||
require 'gusteau/metadata' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Gusteau | ||
VERSION = "0.4.2" | ||
DESCRIPTION = %q{A fine Chef Solo wrapper} | ||
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 was deleted.
Oops, something went wrong.