Sha256: ac538e807eab1747cf6184fe01cca9d4f5fe65f759c5ebd67773d8d04a24c614

Contents?: true

Size: 899 Bytes

Versions: 4

Compression:

Stored size: 899 Bytes

Contents

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

module Chake
  class ConfigManager
    class Chef < ConfigManager
      CONFIG = ENV['CHAKE_CHEF_CONFIG'] || 'config.rb'

      def converge
        node.run_as_root "sh -c 'rm -f #{node.path}/nodes/*.json && chef-solo -c #{node.path}/#{CONFIG} #{logging} -j #{json_config}'"
      end

      def apply(config)
        node.run_as_root "sh -c 'rm -f #{node.path}/nodes/*.json && chef-solo -c #{node.path}/#{CONFIG} #{logging} -j #{json_config} --override-runlist recipe[#{config}]'"
      end

      priority 99

      def self.accept?(_node)
        true # this is the default, but after everything else
      end

      private

      def json_config
        parts = [node.path, Chake.tmpdir, "#{node.hostname}.json"].compact
        File.join(parts)
      end

      def logging
        (node.silent && '-l fatal') || ''
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chake-0.92 lib/chake/config_manager/chef.rb
chake-0.91 lib/chake/config_manager/chef.rb
chake-0.90.3 lib/chake/config_manager/chef.rb
chake-0.90.2 lib/chake/config_manager/chef.rb