lib/itamae-mitsurin/cli.rb in itamae-mitsurin-0.24 vs lib/itamae-mitsurin/cli.rb in itamae-mitsurin-0.26
- old
+ new
@@ -21,20 +21,23 @@
option :node_yaml, type: :string, aliases: ['-y']
option :dry_run, type: :boolean, aliases: ['-n']
option :shell, type: :string, default: "/bin/sh"
option :ohai, type: :boolean, default: false, desc: "This option is DEPRECATED and will be unavailable."
option :profile, type: :string, desc: "[EXPERIMENTAL] Save profiling data", banner: "PATH"
+ option :detailed_exitcode, type: :boolean, default: false, desc: "exit code 0 - The run succeeded with no changes or failures, exit code 1 - The run failed, exit code 2 - The run succeeded, and some resources were changed"
+
+
end
desc "local RECIPE [RECIPE...]", "Run Itamae locally"
define_exec_options
def local(*recipe_files)
if recipe_files.empty?
raise "Please specify recipe files."
end
- Runner.run(recipe_files, :local, options)
+ run(recipe_files, :local, options)
end
desc "ssh RECIPE [RECIPE...]", "Run Itamae via ssh"
define_exec_options
option :host, type: :string, aliases: ['-h']
@@ -51,11 +54,11 @@
unless options[:host] || options[:vagrant]
raise "Please set '-h <hostname>' or '--vagrant'"
end
- Runner.run(recipe_files, :ssh, options)
+ run(recipe_files, :local, options)
end
desc "docker RECIPE [RECIPE...]", "Create Docker image"
define_exec_options
option :image, type: :string, desc: "This option or 'container' option is required."
@@ -64,11 +67,11 @@
def docker(*recipe_files)
if recipe_files.empty?
raise "Please specify recipe files."
end
- Runner.run(recipe_files, :docker, options)
+ run(recipe_files, :local, options)
end
desc "version", "Print version"
def version
puts "itamae-mitsurin v#{ItamaeMitsurin::VERSION}"
@@ -78,9 +81,16 @@
def options
@itamae_options ||= super.dup.tap do |options|
if config = options[:config]
options.merge!(YAML.load_file(config))
end
+ end
+ end
+
+ def run(recipe_files, backend_type, options)
+ runner = Runner.run(recipe_files, backend_type, options)
+ if options[:detailed_exitcode] && runner.diff?
+ exit 2
end
end
end
end