Sha256: 974e87df1ec680321c7d69be34726a5aeca7e23614d22c1332c76bfa544fcfb0

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 KB

Contents

require 'chef/knife'

module KnifeSpork
  class SporkNodeRunListAdd < Chef::Knife

    deps do
      require 'knife-spork/runner'
    end

    banner 'knife spork node run_list add [NODE] [ENTRY[,ENTRY]] (options)'


    option :after,
           :short => "-a ITEM",
           :long  => "--after ITEM",
           :description => "Place the ENTRY in the run list after ITEM"

    def run
      self.class.send(:include, KnifeSpork::Runner)
      self.config = Chef::Config.merge!(config)

      if @name_args.empty?
        show_usage
        ui.error("You must specify a node name and item to add")
        exit 1
      end

      @object_name = @name_args.first

      @object_secondary_name = @name_args[1..-1].map do |entry|
        entry.split(',').map { |e| e.strip }
      end.flatten.to_s

      run_plugins(:before_noderunlistadd)
      pre_node = load_node(@object_name)
      node_runlistadd
      post_node = load_node(@object_name)
      @object_difference = json_diff(pre_node,post_node).to_s
      run_plugins(:after_noderunlistadd)
    end

    private
    def node_runlistadd
      nrla = Chef::Knife::NodeRunListAdd.new
      nrla.name_args = @name_args
      nrla.config[:editor] = config[:editor]
      nrla.config[:after] = config[:after]
      nrla.run
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
knife-spork-1.7.2 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.7.1 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.7.0 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.6.3 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.6.2 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.6.1 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.6.0 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.5.1 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.5.0 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.4.2 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.4.1 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.4.0 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.3.4 lib/chef/knife/spork-node-runlistadd.rb
knife-spork-1.3.3 lib/chef/knife/spork-node-runlistadd.rb