summaryrefslogtreecommitdiff
path: root/chef/bin
diff options
context:
space:
mode:
authorBryan McLellan <bryanm@widemile.com>2008-10-13 16:44:09 -0700
committerBryan McLellan <bryanm@widemile.com>2008-10-13 16:44:09 -0700
commit49d2c20c81ce942955fbbf0ab3ff22373051f284 (patch)
tree6ba27f017158497f95d4d7600b9156de68531498 /chef/bin
parentde1bc77f177f20b5d9a95cac546d1dadfd116bcb (diff)
parent0c99f89fcb2a74de5d8638f7f503e5aa8f52b72e (diff)
downloadchef-49d2c20c81ce942955fbbf0ab3ff22373051f284.tar.gz
Merge branch 'master' of git@github.com:hjkp/chef into hjk
Diffstat (limited to 'chef/bin')
-rwxr-xr-xchef/bin/chef-client84
-rwxr-xr-xchef/bin/chef-solo65
2 files changed, 149 insertions, 0 deletions
diff --git a/chef/bin/chef-client b/chef/bin/chef-client
new file mode 100755
index 0000000000..210309de7a
--- /dev/null
+++ b/chef/bin/chef-client
@@ -0,0 +1,84 @@
+#!/usr/bin/env ruby
+#
+# ./chef-client - Build a meal with chef
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'optparse'
+require 'rubygems'
+require 'chef'
+require 'facter'
+require 'json'
+
+config = {
+ :config_file => "/etc/chef/client.rb",
+ :log_level => :info,
+ :json_attribs => nil,
+ :noop => false,
+ :validation_token => nil
+}
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: #{$0} [-d DIR|-r FILE] (options)"
+ opts.on("-c CONFIG", "--config CONFIG", "The Chef Config file to use") do |c|
+ config[:config_file] = c
+ end
+ opts.on("-j JSON_ATTRIBS", "--json-attributes JSON_ATTRIBS", "Load attributes from a JSON file") do |j|
+ config[:json_attribs] = j
+ end
+ opts.on("-n", "--noop", "Print what you would do, but don't actually do it.") do
+ config[:noop] = true
+ end
+ opts.on_tail("-l LEVEL", "--loglevel LEVEL", "Set the log level (debug, info, warn, error, fatal)") do |l|
+ config[:log_level] = l.to_sym
+ end
+
+ opts.on_tail("-t TOKEN", "--token TOKEN", "Set the openid validation token") do |t|
+ config[:validation_token] = t
+ end
+ opts.on_tail("-h", "--help", "Show this message") do
+ puts opts
+ exit
+ end
+end
+opts.parse!(ARGV)
+
+unless File.exists?(config[:config_file]) && File.readable?(config[:config_file])
+ puts "I cannot find or read the config file: #{config[:config_file]}"
+ puts opts
+ exit 1
+end
+
+if config[:json_attribs]
+ unless File.exists?(config[:json_attribs])
+ puts "I cannot find #{config[:json_attribs]}"
+ exit 2
+ end
+ config[:json_attribs] = JSON.parse(IO.read(config[:json_attribs]))
+end
+
+
+
+# Load our config file
+Chef::Config.from_file(config[:config_file])
+if config[:log_level]
+ Chef::Log.level(config[:log_level].to_sym)
+end
+
+c = Chef::Client.new
+c.json_attribs = config[:json_attribs]
+c.validation_token = config[:validation_token]
+c.run
diff --git a/chef/bin/chef-solo b/chef/bin/chef-solo
new file mode 100755
index 0000000000..3e08045a30
--- /dev/null
+++ b/chef/bin/chef-solo
@@ -0,0 +1,65 @@
+#!/usr/bin/env ruby
+#
+# ./chef-client - Build a meal with chef
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+$: << File.join(File.dirname(__FILE__), "..", "lib")
+
+require 'optparse'
+require 'chef'
+require 'rubygems'
+require 'facter'
+
+config = {
+ :config_file => "/etc/chef/client.rb",
+ :log_level => :info,
+ :noop => false
+}
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: #{$0} [-d DIR|-r FILE] (options)"
+ opts.on("-c CONFIG", "--config CONFIG", "The Chef Config file to use") do |c|
+ config[:config_file] = c
+ end
+ opts.on("-n", "--noop", "Print what you would do, but don't actually do it.") do
+ config[:noop] = true
+ end
+ opts.on_tail("-l LEVEL", "--loglevel LEVEL", "Set the log level (debug, info, warn, error, fatal)") do |l|
+ config[:log_level] = l.to_sym
+ end
+ opts.on_tail("-h", "--help", "Show this message") do
+ puts opts
+ exit
+ end
+end
+opts.parse!(ARGV)
+
+unless File.exists?(config[:config_file]) && File.readable?(config[:config_file])
+ puts "I cannot find or read the config file: #{config[:config_file]}"
+ puts opts
+ exit
+end
+
+# Load our config file
+Chef::Config.from_file(config[:config_file])
+if config[:log_level]
+ Chef::Log.level(config[:log_level].to_sym)
+end
+
+c = Chef::Client.new
+c.run_solo \ No newline at end of file