Sha256: a5fedefadbbbaa59b1c8131445e23bd697739194647eb0c18a3d1869a1c74954

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

module Bagboy
  module Chef
    class Knife

      include Singleton

      def setup( opts={} )
        
      end

      def update_item ( data_bag, item )
        execute_command knife_command('data bag', "from file #{data_bag} #{item}.json")
      end

      def create_data_bag ( data_bag )
        execute_command knife_command('data bag', "create #{data_bag}")
      end

      def knife_command ( command, subcommand )
        "cd #{Bagboy.chef_repo}; knife #{command} #{key_config.to_s}#{config_file_config.to_s}#{subcommand}"
      end

      private

      def key_config
         "-k #{Bagboy.key_path} " if Bagboy.key_path != ''
      end

      def config_file_config
        "-c #{Bagboy.config_path} " if Bagboy.config_path != ''
      end

      def execute_command cmd
        `#{cmd}`
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bagboy-0.0.1 lib/bagboy/chef/knife.rb