Sha256: 7169ff53f69b4bd47ef85b5425e34f6b4264411a40ef77df6b4ef9f46af1e821

Contents?: true

Size: 886 Bytes

Versions: 2

Compression:

Stored size: 886 Bytes

Contents

require 'shellwords'
require 'chake/config'
require 'chake/tmpdir'

module Chake
  class ConfigManager
    class ItamaeRemote < ConfigManager
      def converge
        recipes = node.data['itamae-remote']
        return if recipes.empty?

        run_itamae(*recipes)
      end

      def apply(config)
        run_itamae(config)
      end

      def needs_upload?
        true
      end

      def self.accept?(node)
        node.data.key?('itamae-remote')
      end

      private

      def run_itamae(*recipes)
        cmd = ['itamae', 'local', "--node-json=#{json_config}"]
        if node.silent
          cmd << '--log-level=warn'
        end
        cmd += recipes.map { |r| File.join(node.path, r) }
        node.run_as_root(Shellwords.join(cmd))
      end

      def json_config
        File.join(node.path, Chake.tmpdir, "#{node.hostname}.json")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chake-0.92 lib/chake/config_manager/itamae_remote.rb
chake-0.91 lib/chake/config_manager/itamae_remote.rb