chef 0.8.4 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chef might be problematic. Click here for more details.
- data/lib/chef.rb +1 -1
 - data/lib/chef/exceptions.rb +1 -0
 - data/lib/chef/knife/client_show.rb +2 -2
 - data/lib/chef/knife/cookbook_upload.rb +8 -5
 - data/lib/chef/knife/node_run_list_add.rb +2 -2
 - data/lib/chef/knife/role_show.rb +2 -2
 - data/lib/chef/knife/search.rb +2 -2
 - data/lib/chef/mixin/command.rb +1 -1
 - data/lib/chef/platform.rb +9 -1
 - data/lib/chef/provider/deploy/revision.rb +1 -1
 - data/lib/chef/resource/user.rb +2 -0
 - data/lib/chef/rest.rb +5 -2
 - data/lib/chef/run_list.rb +24 -16
 - metadata +6 -18
 
    
        data/lib/chef.rb
    CHANGED
    
    
    
        data/lib/chef/exceptions.rb
    CHANGED
    
    
| 
         @@ -27,8 +27,8 @@ class Chef 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  banner "Sub-Command: client show CLIENT (options)"
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                  option :attribute,
         
     | 
| 
       30 
     | 
    
         
            -
                    :short => "-a  
     | 
| 
       31 
     | 
    
         
            -
                    :long => "--attribute  
     | 
| 
      
 30 
     | 
    
         
            +
                    :short => "-a ATTR",
         
     | 
| 
      
 31 
     | 
    
         
            +
                    :long => "--attribute ATTR",
         
     | 
| 
       32 
32 
     | 
    
         
             
                    :description => "Show only one attribute"
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                  def run 
         
     | 
| 
         @@ -25,7 +25,7 @@ class Chef 
     | 
|
| 
       25 
25 
     | 
    
         
             
              class Knife
         
     | 
| 
       26 
26 
     | 
    
         
             
                class CookbookUpload < Knife
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                  banner "Sub-Command: cookbook upload  
     | 
| 
      
 28 
     | 
    
         
            +
                  banner "Sub-Command: cookbook upload [COOKBOOKS...] (options)"
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                  option :cookbook_path,
         
     | 
| 
       31 
31 
     | 
    
         
             
                    :short => "-o PATH:PATH",
         
     | 
| 
         @@ -52,17 +52,20 @@ class Chef 
     | 
|
| 
       52 
52 
     | 
    
         
             
                        upload_cookbook(cookbook.name.to_s)
         
     | 
| 
       53 
53 
     | 
    
         
             
                      end
         
     | 
| 
       54 
54 
     | 
    
         
             
                    else
         
     | 
| 
       55 
     | 
    
         
            -
                       
     | 
| 
      
 55 
     | 
    
         
            +
                      @name_args.each do |cb|
         
     | 
| 
      
 56 
     | 
    
         
            +
                        Chef::Log.info("** #{cb} **")
         
     | 
| 
      
 57 
     | 
    
         
            +
                        upload_cookbook(cb)
         
     | 
| 
      
 58 
     | 
    
         
            +
                      end
         
     | 
| 
       56 
59 
     | 
    
         
             
                    end
         
     | 
| 
       57 
60 
     | 
    
         
             
                  end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
                  
         
     | 
| 
       59 
62 
     | 
    
         
             
                  def test_ruby(cookbook_dir)
         
     | 
| 
       60 
63 
     | 
    
         
             
                    Dir[File.join(cookbook_dir, '**', '*.rb')].each do |ruby_file|
         
     | 
| 
       61 
64 
     | 
    
         
             
                      Chef::Log.info("Testing #{ruby_file} for syntax errors...")
         
     | 
| 
       62 
65 
     | 
    
         
             
                      Chef::Mixin::Command.run_command(:command => "ruby -c #{ruby_file}")
         
     | 
| 
       63 
66 
     | 
    
         
             
                    end
         
     | 
| 
       64 
67 
     | 
    
         
             
                  end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
                  
         
     | 
| 
       66 
69 
     | 
    
         
             
                  def test_templates(cookbook_dir)
         
     | 
| 
       67 
70 
     | 
    
         
             
                    Dir[File.join(cookbook_dir, '**', '*.erb')].each do |erb_file|
         
     | 
| 
       68 
71 
     | 
    
         
             
                      Chef::Log.info("Testing template #{erb_file} for syntax errors...")
         
     | 
| 
         @@ -166,7 +169,7 @@ class Chef 
     | 
|
| 
       166 
169 
     | 
    
         
             
                    Chef::Log.debug("Removing local staging directory at #{tmp_cookbook_dir}")
         
     | 
| 
       167 
170 
     | 
    
         
             
                    FileUtils.rm_rf tmp_cookbook_dir
         
     | 
| 
       168 
171 
     | 
    
         
             
                  end
         
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
      
 172 
     | 
    
         
            +
                  
         
     | 
| 
       170 
173 
     | 
    
         
             
                end
         
     | 
| 
       171 
174 
     | 
    
         
             
              end
         
     | 
| 
       172 
175 
     | 
    
         
             
            end
         
     | 
| 
         @@ -27,8 +27,8 @@ class Chef 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  banner "Sub-Command: node run_list add [NODE] [ENTRY] (options)"
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                  option :after,
         
     | 
| 
       30 
     | 
    
         
            -
                    :short => "-a  
     | 
| 
       31 
     | 
    
         
            -
                    :long  => "--after  
     | 
| 
      
 30 
     | 
    
         
            +
                    :short => "-a ITEM",
         
     | 
| 
      
 31 
     | 
    
         
            +
                    :long  => "--after ITEM",
         
     | 
| 
       32 
32 
     | 
    
         
             
                    :description => "Place the ENTRY in the run list after ITEM"
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                  def run 
         
     | 
    
        data/lib/chef/knife/role_show.rb
    CHANGED
    
    | 
         @@ -27,8 +27,8 @@ class Chef 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  banner "Sub-Command: role show ROLE (options)"
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                  option :attribute,
         
     | 
| 
       30 
     | 
    
         
            -
                    :short => "-a  
     | 
| 
       31 
     | 
    
         
            -
                    :long => "--attribute  
     | 
| 
      
 30 
     | 
    
         
            +
                    :short => "-a ATTR",
         
     | 
| 
      
 31 
     | 
    
         
            +
                    :long => "--attribute ATTR",
         
     | 
| 
       32 
32 
     | 
    
         
             
                    :description => "Show only one attribute"
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                  def run 
         
     | 
    
        data/lib/chef/knife/search.rb
    CHANGED
    
    
    
        data/lib/chef/mixin/command.rb
    CHANGED
    
    | 
         @@ -171,7 +171,7 @@ class Chef 
     | 
|
| 
       171 
171 
     | 
    
         
             
                      if status.exitstatus != args[:returns]
         
     | 
| 
       172 
172 
     | 
    
         
             
                        # if the log level is not debug, through output of command when we fail
         
     | 
| 
       173 
173 
     | 
    
         
             
                        output = ""
         
     | 
| 
       174 
     | 
    
         
            -
                        if Chef::Log. 
     | 
| 
      
 174 
     | 
    
         
            +
                        if Chef::Log.level == :debug
         
     | 
| 
       175 
175 
     | 
    
         
             
                          output << "\n---- Begin output of #{args[:command]} ----\n"
         
     | 
| 
       176 
176 
     | 
    
         
             
                          output << "#{command_output}"
         
     | 
| 
       177 
177 
     | 
    
         
             
                          output << "---- End output of #{args[:command]} ----\n"
         
     | 
    
        data/lib/chef/platform.rb
    CHANGED
    
    | 
         @@ -67,7 +67,15 @@ class Chef 
     | 
|
| 
       67 
67 
     | 
    
         
             
                      :mdadm => Chef::Provider::Mdadm
         
     | 
| 
       68 
68 
     | 
    
         
             
                    }
         
     | 
| 
       69 
69 
     | 
    
         
             
                  },
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
                  :fedora   => {
         
     | 
| 
      
 71 
     | 
    
         
            +
                    :default => {
         
     | 
| 
      
 72 
     | 
    
         
            +
                      :service => Chef::Provider::Service::Redhat,
         
     | 
| 
      
 73 
     | 
    
         
            +
                      :cron => Chef::Provider::Cron,
         
     | 
| 
      
 74 
     | 
    
         
            +
                      :package => Chef::Provider::Package::Yum,
         
     | 
| 
      
 75 
     | 
    
         
            +
                      :mdadm => Chef::Provider::Mdadm
         
     | 
| 
      
 76 
     | 
    
         
            +
                    }
         
     | 
| 
      
 77 
     | 
    
         
            +
                  },
         
     | 
| 
      
 78 
     | 
    
         
            +
                  :suse     => {
         
     | 
| 
       71 
79 
     | 
    
         
             
                    :default => {
         
     | 
| 
       72 
80 
     | 
    
         
             
                      :service => Chef::Provider::Service::Redhat,
         
     | 
| 
       73 
81 
     | 
    
         
             
                      :cron => Chef::Provider::Cron,
         
     | 
    
        data/lib/chef/resource/user.rb
    CHANGED
    
    
    
        data/lib/chef/rest.rb
    CHANGED
    
    | 
         @@ -40,10 +40,11 @@ class Chef 
     | 
|
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                attr_accessor :url, :cookies, :client_name, :signing_key, :signing_key_filename, :sign_on_redirect, :sign_request
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                def initialize(url, client_name=Chef::Config[:node_name], signing_key_filename=Chef::Config[:client_key])
         
     | 
| 
      
 43 
     | 
    
         
            +
                def initialize(url, client_name=Chef::Config[:node_name], signing_key_filename=Chef::Config[:client_key], options={})
         
     | 
| 
       44 
44 
     | 
    
         
             
                  @url = url
         
     | 
| 
       45 
45 
     | 
    
         
             
                  @cookies = CookieJar.instance
         
     | 
| 
       46 
46 
     | 
    
         
             
                  @client_name = client_name
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @default_headers = options[:headers] || {}
         
     | 
| 
       47 
48 
     | 
    
         
             
                  if signing_key_filename
         
     | 
| 
       48 
49 
     | 
    
         
             
                    @signing_key_filename = signing_key_filename
         
     | 
| 
       49 
50 
     | 
    
         
             
                    @signing_key = load_signing_key(signing_key_filename) 
         
     | 
| 
         @@ -177,7 +178,9 @@ class Chef 
     | 
|
| 
       177 
178 
     | 
    
         
             
                  end
         
     | 
| 
       178 
179 
     | 
    
         | 
| 
       179 
180 
     | 
    
         
             
                  http.read_timeout = Chef::Config[:rest_timeout]
         
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
      
 181 
     | 
    
         
            +
                  
         
     | 
| 
      
 182 
     | 
    
         
            +
                  headers = @default_headers.merge(headers)
         
     | 
| 
      
 183 
     | 
    
         
            +
                  
         
     | 
| 
       181 
184 
     | 
    
         
             
                  unless raw
         
     | 
| 
       182 
185 
     | 
    
         
             
                    headers = headers.merge({ 
         
     | 
| 
       183 
186 
     | 
    
         
             
                      'Accept' => "application/json",
         
     | 
    
        data/lib/chef/run_list.rb
    CHANGED
    
    | 
         @@ -116,7 +116,7 @@ class Chef 
     | 
|
| 
       116 
116 
     | 
    
         
             
                  self
         
     | 
| 
       117 
117 
     | 
    
         
             
                end
         
     | 
| 
       118 
118 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
                def expand(from='server', couchdb=nil)
         
     | 
| 
      
 119 
     | 
    
         
            +
                def expand(from='server', couchdb=nil, rest=nil)
         
     | 
| 
       120 
120 
     | 
    
         
             
                  couchdb = couchdb ? couchdb : Chef::CouchDB.new
         
     | 
| 
       121 
121 
     | 
    
         
             
                  recipes = Array.new
         
     | 
| 
       122 
122 
     | 
    
         
             
                  default_attrs = Mash.new
         
     | 
| 
         @@ -128,21 +128,29 @@ class Chef 
     | 
|
| 
       128 
128 
     | 
    
         
             
                    when 'recipe'
         
     | 
| 
       129 
129 
     | 
    
         
             
                      recipes << name unless recipes.include?(name)
         
     | 
| 
       130 
130 
     | 
    
         
             
                    when 'role'
         
     | 
| 
       131 
     | 
    
         
            -
                      role =  
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
      
 131 
     | 
    
         
            +
                      role = begin
         
     | 
| 
      
 132 
     | 
    
         
            +
                               next if @seen_roles.include?(name)
         
     | 
| 
      
 133 
     | 
    
         
            +
                               @seen_roles << name
         
     | 
| 
      
 134 
     | 
    
         
            +
                               if from == 'disk' || Chef::Config[:solo]
         
     | 
| 
      
 135 
     | 
    
         
            +
                                 # Load the role from disk
         
     | 
| 
      
 136 
     | 
    
         
            +
                                 Chef::Role.from_disk("#{name}") || Chef::Exceptions::RoleNotFound
         
     | 
| 
      
 137 
     | 
    
         
            +
                               elsif from == 'server'
         
     | 
| 
      
 138 
     | 
    
         
            +
                                 # Load the role from the server
         
     | 
| 
      
 139 
     | 
    
         
            +
                                 begin
         
     | 
| 
      
 140 
     | 
    
         
            +
                                   (rest || Chef::REST.new(Chef::Config[:role_url])).get_rest("roles/#{name}") 
         
     | 
| 
      
 141 
     | 
    
         
            +
                                 rescue Net::HTTPServerException
         
     | 
| 
      
 142 
     | 
    
         
            +
                                   raise Chef::Exceptions::RoleNotFound if $!.message == '404 "Not Found"'
         
     | 
| 
      
 143 
     | 
    
         
            +
                                   raise
         
     | 
| 
      
 144 
     | 
    
         
            +
                                 end
         
     | 
| 
      
 145 
     | 
    
         
            +
                               elsif from == 'couchdb'
         
     | 
| 
      
 146 
     | 
    
         
            +
                                 # Load the role from couchdb
         
     | 
| 
      
 147 
     | 
    
         
            +
                                 Chef::Role.cdb_load(name, couchdb) rescue Chef::Exceptions::CouchDBNotFound raise(Chef::Exceptions::RoleNotFound)
         
     | 
| 
      
 148 
     | 
    
         
            +
                               end
         
     | 
| 
      
 149 
     | 
    
         
            +
                             rescue Chef::Exceptions::RoleNotFound
         
     | 
| 
      
 150 
     | 
    
         
            +
                               Chef::Log.error("Role #{name} is in the runlist but does not exist. Skipping expand.")
         
     | 
| 
      
 151 
     | 
    
         
            +
                               next
         
     | 
| 
      
 152 
     | 
    
         
            +
                             end
         
     | 
| 
      
 153 
     | 
    
         
            +
                      rec, d, o = role.run_list.expand(from, couchdb, rest)
         
     | 
| 
       146 
154 
     | 
    
         
             
                      rec.each { |r| recipes <<  r unless recipes.include?(r) }
         
     | 
| 
       147 
155 
     | 
    
         
             
                      default_attrs = Chef::Mixin::DeepMerge.merge(default_attrs, Chef::Mixin::DeepMerge.merge(role.default_attributes,d))
         
     | 
| 
       148 
156 
     | 
    
         
             
                      override_attrs = Chef::Mixin::DeepMerge.merge(override_attrs, Chef::Mixin::DeepMerge.merge(role.override_attributes, o))
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 8
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              version: 0.8. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 6
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.8.6
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - Adam Jacob
         
     | 
| 
         @@ -14,7 +14,7 @@ autorequire: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2010-03- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-03-04 00:00:00 -08:00
         
     | 
| 
       18 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -82,9 +82,9 @@ dependencies: 
     | 
|
| 
       82 
82 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       83 
83 
     | 
    
         
             
                    segments: 
         
     | 
| 
       84 
84 
     | 
    
         
             
                    - 0
         
     | 
| 
       85 
     | 
    
         
            -
                    -  
     | 
| 
      
 85 
     | 
    
         
            +
                    - 5
         
     | 
| 
       86 
86 
     | 
    
         
             
                    - 0
         
     | 
| 
       87 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 87 
     | 
    
         
            +
                    version: 0.5.0
         
     | 
| 
       88 
88 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       89 
89 
     | 
    
         
             
              version_requirements: *id005
         
     | 
| 
       90 
90 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -150,7 +150,7 @@ dependencies: 
     | 
|
| 
       150 
150 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       151 
151 
     | 
    
         
             
              version_requirements: *id010
         
     | 
| 
       152 
152 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       153 
     | 
    
         
            -
              name:  
     | 
| 
      
 153 
     | 
    
         
            +
              name: moneta
         
     | 
| 
       154 
154 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       155 
155 
     | 
    
         
             
              requirement: &id011 !ruby/object:Gem::Requirement 
         
     | 
| 
       156 
156 
     | 
    
         
             
                requirements: 
         
     | 
| 
         @@ -161,18 +161,6 @@ dependencies: 
     | 
|
| 
       161 
161 
     | 
    
         
             
                    version: "0"
         
     | 
| 
       162 
162 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       163 
163 
     | 
    
         
             
              version_requirements: *id011
         
     | 
| 
       164 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       165 
     | 
    
         
            -
              name: moneta
         
     | 
| 
       166 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       167 
     | 
    
         
            -
              requirement: &id012 !ruby/object:Gem::Requirement 
         
     | 
| 
       168 
     | 
    
         
            -
                requirements: 
         
     | 
| 
       169 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       170 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
         
     | 
| 
       171 
     | 
    
         
            -
                    segments: 
         
     | 
| 
       172 
     | 
    
         
            -
                    - 0
         
     | 
| 
       173 
     | 
    
         
            -
                    version: "0"
         
     | 
| 
       174 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       175 
     | 
    
         
            -
              version_requirements: *id012
         
     | 
| 
       176 
164 
     | 
    
         
             
            description: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
         
     | 
| 
       177 
165 
     | 
    
         
             
            email: adam@opscode.com
         
     | 
| 
       178 
166 
     | 
    
         
             
            executables: 
         
     |