Sha256: 936b0bde3608313cc065aaa7eefef46357a3156984c48652c49be506ffda205e

Contents?: true

Size: 897 Bytes

Versions: 6

Compression:

Stored size: 897 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

6 entries across 6 versions & 1 rubygems

Version Path
chake-0.90.1 lib/chake/config_manager/chef.rb
chake-0.90 lib/chake/config_manager/chef.rb
chake-0.82 lib/chake/config_manager/chef.rb
chake-0.81.1 lib/chake/config_manager/chef.rb
chake-0.81 lib/chake/config_manager/chef.rb
chake-0.80 lib/chake/config_manager/chef.rb