#!/usr/bin/env ruby require 'lambom' require 'lambom/version' require 'optparse' # -e environment # -j json_file # -s server # -l loglevel # -k private_key_file options = {} OptionParser.new do |opts| opts.banner = "Usage: lambom [options]" opts.on("-A", "--api [API ENDPOINT URL]", "RIYIC Api endpoint to connect to download the server configuration") do |j| options[:api_url] = j end opts.on("-j", "--json [JSON FILE]", "Run server convergence with configuration from json attributes file") do |j| options[:json_file] = j end # opts.on("-b", "--berksfile [BERKSFILE FILE]", # "Use specified berksfile to download cookbooks and dependencies") do |j| # options[:berksfile] = b # end opts.on("-c", "--cached", "Use local cached cookbooks") do options[:cached] = true end opts.on("-D", "--download [TARBALL URL]", "Download cookbooks tarball from url and unpack it in cookbooks chef path") do |d| options[:download_tarball] = d end opts.on("-e", "--env [ENVIRONMENT]", "Select environment") do |e| options[:environment] = e end opts.on("-s", "--server [SERVER_UUID]", "Sets the server uuid to which to download configuration from RIYIC api") do |s| options[:server] = s end opts.on("-k", "--keyfile [PRIVATE KEYFILE]", "PEM Private keyfile to sign api requests") do |k| options[:private_key_file] = k end opts.on("-l","--loglevel [LOG_LEVEL]", "Set loglevel") do |l| options[:loglevel] = l end opts.on("-d","--debug", "Debug mode") do Lambom.enable_debug end opts.on_tail("-v", "--version", "Show version") do puts Lambom::VERSION exit end end.parse! out = '' begin out = Lambom.run(options) rescue StandardError => e puts "Error: #{e.message}" exit 1 rescue SystemExit => s unless s.success? puts "Error executing convergence: #{out}" exit s.status end end puts "Command executed successfully"