Sha256: de11e20b6dcdc30ca3504eb8e4e8d312d25d08461a3bfa4cd0cd775e9f0aab42
Contents?: true
Size: 1.56 KB
Versions: 17
Compression:
Stored size: 1.56 KB
Contents
require 'itamae' require 'json' module Itamae class Runner class << self def run(recipe_files, backend_type, options) set_backend_from_options(backend_type, options) runner = self.new(node_from_options(options)) recipe_files.each do |path| recipe = Recipe.new(runner, File.expand_path(path)) recipe.run(dry_run: options[:dry_run]) end end private def node_from_options(options) hash = {} if options[:ohai] Logger.info "Loading node data via ohai..." hash.merge!(JSON.parse(Backend.instance.run_command("ohai").stdout)) end if options[:node_json] path = File.expand_path(options[:node_json]) Logger.info "Loading node data from #{path}..." hash.merge!(JSON.load(open(path))) end Node.new(hash) end def set_backend_from_options(type, options) opts = {} case type when :local # do nothing when :ssh opts[:host] = options[:host] opts[:user] = options[:user] || Etc.getlogin opts[:keys] = [options[:key]] if options[:key] opts[:port] = options[:port] if options[:port] end Backend.instance.set_type(type, opts) end end attr_accessor :node attr_accessor :tmpdir def initialize(node) @node = node @tmpdir = "/tmp/itamae_tmp" Backend.instance.run_command(["mkdir", "-p", @tmpdir]) Backend.instance.run_command(["chmod", "777", @tmpdir]) end end end
Version data entries
17 entries across 17 versions & 1 rubygems