Created
December 14, 2010 21:13
-
-
Save mattray/741104 to your computer and use it in GitHub Desktop.
apt_repository LWRP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mray@ubuntu1004:/etc/apt/sources.list.d$ sudo chef-client | |
[Tue, 14 Dec 2010 15:05:49 -0600] INFO: Starting Chef Run (Version 0.9.12) | |
[Tue, 14 Dec 2010 15:05:51 -0600] INFO: Storing updated cookbooks/apt/providers/repository.rb in the cache. | |
[Tue, 14 Dec 2010 15:05:53 -0600] INFO: Ran execute[apt-get update] successfully | |
[Tue, 14 Dec 2010 15:05:53 -0600] INFO: Zenoss Server: http://dev.zenoss.org/deb main stable | |
[Tue, 14 Dec 2010 15:05:53 -0600] INFO: APT 1:false | |
[Tue, 14 Dec 2010 15:05:53 -0600] INFO: APT 2::deb | |
[Tue, 14 Dec 2010 15:05:53 -0600] INFO: APT 3::deb | |
[Tue, 14 Dec 2010 15:05:53 -0600] INFO: APT 4::deb | |
[Tue, 14 Dec 2010 15:05:53 -0600] ERROR: apt_repository[deb http://dev.zenoss.org/deb main stable] (/var/chef/cache/cookbooks/zenoss/recipes/server.rb:26:in `from_file') had an error: | |
undefined method `each' for nil:NilClass | |
/var/chef/cache/cookbooks/apt/providers/repository.rb:11:in `class_from_file' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider.rb:104:in `instance_eval' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider.rb:104:in `action_add_source' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource.rb:395:in `send' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource.rb:395:in `run_action' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:53:in `run_action' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:89:in `converge' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:89:in `each' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:89:in `converge' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection.rb:94 | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in `step' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection.rb:92:in `execute_each_resource' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:84:in `converge' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/client.rb:268:in `converge' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/client.rb:171:in `run' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/application/client.rb:222:in `run_application' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/application/client.rb:212:in `loop' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/application/client.rb:212:in `run_application' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/application.rb:62:in `run' | |
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/chef-client:26 | |
/usr/bin/chef-client:19:in `load' | |
/usr/bin/chef-client:19 | |
[Tue, 14 Dec 2010 15:05:53 -0600] ERROR: Running exception handlers | |
[Tue, 14 Dec 2010 15:05:53 -0600] ERROR: Exception handlers complete | |
/var/chef/cache/cookbooks/apt/providers/repository.rb:11:in `class_from_file': undefined method `each' for nil:NilClass (NoMethodError) | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider.rb:104:in `instance_eval' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/provider.rb:104:in `action_add_source' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource.rb:395:in `send' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource.rb:395:in `run_action' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:53:in `run_action' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:89:in `converge' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:89:in `each' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:89:in `converge' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection.rb:94 | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in `step' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/resource_collection.rb:92:in `execute_each_resource' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:84:in `converge' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/client.rb:268:in `converge' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/client.rb:171:in `run' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/application/client.rb:222:in `run_application' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/application/client.rb:212:in `loop' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/application/client.rb:212:in `run_application' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/application.rb:62:in `run' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/chef-client:26 | |
from /usr/bin/chef-client:19:in `load' | |
from /usr/bin/chef-client:19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
action :add_source do | |
#build our listing | |
Chef::Log.info "APT 1:#{new_resource.deb_src}" | |
repository = "deb" | |
repository = "deb_src" if new_resource.deb_src | |
Chef::Log.info "APT 2:#{new_resource.uri}:#{repository}" | |
repository = "#{repository} #{new_resource.uri}" | |
Chef::Log.info "APT 3:#{new_resource.distribution}:#{repository}" | |
repository = "#{repository} #{new_resource.distribution}" | |
Chef::Log.info "APT 4:#{new_resource.components}:#{repository}" | |
new_resource.components.each {|component| repository += " #{component}"} | |
Chef::Log.info "Adding apt repository #{repository} to /etc/apt/sources.list.d/chef_sources.list" | |
#write to the file | |
File.open("/etc/apt/sources.list.d/chef_sources.list", "w") do |file| | |
file.puts repository | |
end | |
end | |
action :remove_source do | |
Chef::Log.info "Removing apt repository from /etc/apt/sources.list.d/chef_sources.list" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
actions :add_source, :remove_source | |
#whether or not to add the repository as a source repo as well | |
attribute :uri, :kind_of => String | |
attribute :deb_src, :default => false | |
attribute :distribution, :kind_of => String | |
attribute :components, :kind_of => Array.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_recipe "apt" | |
# Zenoss apt repository | |
apt_repository "deb http://dev.zenoss.org/deb main stable" do | |
uri = "http://dev.zenoss.org/deb" | |
distribution = "main" | |
components = ["stable"] | |
Chef::Log.info("Zenoss Server: #{uri} #{distribution} #{components}") | |
action :add_source | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment