Skip to content

Commit

Permalink
Import apt version 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xdissent committed Dec 18, 2011
1 parent af262d0 commit 595d0e0
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 29 deletions.
25 changes: 21 additions & 4 deletions cookbooks/apt/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
Description
===========

Configures various APT components on Debian-like systems. Also includes a LWRP.
This cookbook includes recipes to execute apt-get update to ensure the local APT package cache is up to date or manage apt-cacher and cacher clients. It also includes a LWRP for managing APT repositories in /etc/apt/sources.list.d.

Changes
=======

## v1.2.2:

* COOK-804: apt-get update resource in apt cookbook changed names

## v1.2.0:

* COOK-136: Limit apt-get update to one run per day unless notified.
* COOK-471: ignore failure on apt-get update
* COOK-533: add support for deb and `deb_src` repos with `apt_repository`

Recipes
=======

default
-------
The default recipe runs apt-get update during the Compile Phase of the Chef run to ensure that the system's package cache is updated with the latest. It is recommended that this recipe appear first in a node's run list (directly or through a role) to ensure that when installing packages, Chef will be able to download the latest version available on the remote APT repository.

This recipe installs the `update-notifier-common` package to provide the timestamp file used to only run `apt-get update` if the cache is less than one day old.

This recipe should appear first in the run list of Debian or Ubuntu nodes to ensure that the package cache is up to date before managing any `package` resources with Chef.

This recipe also sets up a local cache directory for preseeding packages.

cacher
------

Installs the apt-cacher package and service so the system can provide APT caching. You can check the usage report at http://{hostname}:3142/report. The cacher recipe includes the `cacher-client` recipe, so it helps seed itself.

cacher-client
Expand All @@ -23,7 +40,7 @@ Configures the node to use the apt-cacher server as a client.
Resources/Providers
===================

This LWRP provides an easy way to manage additional APT repositories.
This LWRP provides an easy way to manage additional APT repositories. Adding a new repository will notify running the `execute[apt-get-update]` resource.

# Actions

Expand All @@ -40,7 +57,7 @@ This LWRP provides an easy way to manage additional APT repositories.
- key_server: the GPG keyserver where the key for the repo should be retrieved
- key: if a `key_server` is provided, this is assumed to be the fingerprint, otherwise it is the URI to the GPG key for the repo

# Example
# Examples

# add the Zenoss repo
apt_repository "zenoss" do
Expand Down
40 changes: 20 additions & 20 deletions cookbooks/apt/metadata.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"dependencies": {
},
"name": "apt",
"description": "Configures apt and apt services and an LWRP for managing apt repositories",
"long_description": "Description\n===========\n\nThis cookbook includes recipes to execute apt-get update to ensure the local APT package cache is up to date or manage apt-cacher and cacher clients. It also includes a LWRP for managing APT repositories in /etc/apt/sources.list.d.\n\nChanges\n=======\n\n## v1.2.2:\n\n* COOK-804: apt-get update resource in apt cookbook changed names\n\n## v1.2.0:\n\n* COOK-136: Limit apt-get update to one run per day unless notified.\n* COOK-471: ignore failure on apt-get update\n* COOK-533: add support for deb and `deb_src` repos with `apt_repository`\n\nRecipes\n=======\n\ndefault\n-------\n\nThis recipe installs the `update-notifier-common` package to provide the timestamp file used to only run `apt-get update` if the cache is less than one day old.\n\nThis recipe should appear first in the run list of Debian or Ubuntu nodes to ensure that the package cache is up to date before managing any `package` resources with Chef.\n\nThis recipe also sets up a local cache directory for preseeding packages.\n\ncacher\n------\n\nInstalls the apt-cacher package and service so the system can provide APT caching. You can check the usage report at http://{hostname}:3142/report. The cacher recipe includes the `cacher-client` recipe, so it helps seed itself.\n\ncacher-client\n-------------\nConfigures the node to use the apt-cacher server as a client.\n\nResources/Providers\n===================\n\nThis LWRP provides an easy way to manage additional APT repositories. Adding a new repository will notify running the `execute[apt-get-update]` resource.\n\n# Actions\n\n- :add: creates a repository file and builds the repository listing\n- :remove: removes the repository file\n\n# Attribute Parameters\n\n- repo_name: name attribute. The name of the channel to discover\n- uri: the base of the Debian distribution\n- distribution: this is usually your release's codename...ie something like `karmic`, `lucid` or `maverick`\n- components: package groupings..when it doubt use `main`\n- deb_src: whether or not to add the repository as a source repo as well\n- key_server: the GPG keyserver where the key for the repo should be retrieved\n- key: if a `key_server` is provided, this is assumed to be the fingerprint, otherwise it is the URI to the GPG key for the repo\n\n# Examples\n\n # add the Zenoss repo\n apt_repository \"zenoss\" do\n uri \"http://dev.zenoss.org/deb\"\n components [\"main\",\"stable\"]\n action :add\n end\n \n # add the Nginx PPA; grab key from keyserver\n apt_repository \"nginx-php\" do\n uri \"http://ppa.launchpad.net/nginx/php5/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n keyserver \"keyserver.ubuntu.com\"\n key \"C300EE8C\"\n action :add\n end\n \n # add the Cloudkick Repo\n apt_repository \"cloudkick\" do\n uri \"http://packages.cloudkick.com/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n key \"http://packages.cloudkick.com/cloudkick.packages.key\"\n action :add\n end\n \n # remove Zenoss repo\n apt_repository \"zenoss\" do\n action :remove\n end\n \nUsage\n=====\n\nPut `recipe[apt]` first in the run list. If you have other recipes that you want to use to configure how apt behaves, like new sources, notify the execute resource to run, e.g.:\n\n template \"/etc/apt/sources.list.d/my_apt_sources.list\" do\n notifies :run, resources(:execute => \"apt-get update\"), :immediately\n end\n\nThe above will run during execution phase since it is a normal template resource, and should appear before other package resources that need the sources in the template.\n\nPut `recipe[apt::cacher]` in the run_list for a server to provide APT caching and add `recipe[apt::cacher-client]` on the rest of the Debian-based nodes to take advantage of the caching server.\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nAuthor:: Matt Ray (<matt@opscode.com>)\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\n\nCopyright 2009-2011 Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"attributes": {
},
"license": "Apache 2.0",
"suggestions": {
},
"platforms": {
"debian": ">= 0.0.0",
"ubuntu": ">= 0.0.0"
"ubuntu": ">= 0.0.0",
"debian": ">= 0.0.0"
},
"maintainer": "Opscode, Inc.",
"long_description": "Description\n===========\n\nConfigures various APT components on Debian-like systems. Also includes a LWRP.\n\nRecipes\n=======\n\ndefault\n-------\nThe default recipe runs apt-get update during the Compile Phase of the Chef run to ensure that the system's package cache is updated with the latest. It is recommended that this recipe appear first in a node's run list (directly or through a role) to ensure that when installing packages, Chef will be able to download the latest version available on the remote APT repository.\n\nThis recipe also sets up a local cache directory for preseeding packages.\n\ncacher\n------\nInstalls the apt-cacher package and service so the system can provide APT caching. You can check the usage report at http://{hostname}:3142/report. The cacher recipe includes the `cacher-client` recipe, so it helps seed itself.\n\ncacher-client\n-------------\nConfigures the node to use the apt-cacher server as a client.\n\nResources/Providers\n===================\n\nThis LWRP provides an easy way to manage additional APT repositories.\n\n# Actions\n\n- :add: creates a repository file and builds the repository listing\n- :remove: removes the repository file\n\n# Attribute Parameters\n\n- repo_name: name attribute. The name of the channel to discover\n- uri: the base of the Debian distribution\n- distribution: this is usually your release's codename...ie something like `karmic`, `lucid` or `maverick`\n- components: package groupings..when it doubt use `main`\n- deb_src: whether or not to add the repository as a source repo as well\n- key_server: the GPG keyserver where the key for the repo should be retrieved\n- key: if a `key_server` is provided, this is assumed to be the fingerprint, otherwise it is the URI to the GPG key for the repo\n\n# Example\n\n # add the Zenoss repo\n apt_repository \"zenoss\" do\n uri \"http://dev.zenoss.org/deb\"\n components [\"main\",\"stable\"]\n action :add\n end\n \n # add the Nginx PPA; grab key from keyserver\n apt_repository \"nginx-php\" do\n uri \"http://ppa.launchpad.net/nginx/php5/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n keyserver \"keyserver.ubuntu.com\"\n key \"C300EE8C\"\n action :add\n end\n \n # add the Cloudkick Repo\n apt_repository \"cloudkick\" do\n uri \"http://packages.cloudkick.com/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n key \"http://packages.cloudkick.com/cloudkick.packages.key\"\n action :add\n end\n \n # remove Zenoss repo\n apt_repository \"zenoss\" do\n action :remove\n end\n \nUsage\n=====\n\nPut `recipe[apt]` first in the run list. If you have other recipes that you want to use to configure how apt behaves, like new sources, notify the execute resource to run, e.g.:\n\n template \"/etc/apt/sources.list.d/my_apt_sources.list\" do\n notifies :run, resources(:execute => \"apt-get update\"), :immediately\n end\n\nThe above will run during execution phase since it is a normal template resource, and should appear before other package resources that need the sources in the template.\n\nPut `recipe[apt::cacher]` in the run_list for a server to provide APT caching and add `recipe[apt::cacher-client]` on the rest of the Debian-based nodes to take advantage of the caching server.\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nAuthor:: Matt Ray (<matt@opscode.com>)\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\n\nCopyright 2009-2011 Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n",
"version": "1.1.2",
"recommendations": {
"dependencies": {
},
"recipes": {
"apt": "Runs apt-get update during compile phase and sets up preseed directories",
"apt::cacher-client": "Client for the apt::cacher server",
"apt::cacher": "Set up an APT cache"
"recommendations": {
},
"groupings": {
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
},
"description": "Configures apt and apt services and an LWRP for managing apt repositories",
"providing": {
}
"attributes": {
},
"groupings": {
},
"recipes": {
"apt": "Runs apt-get update during compile phase and sets up preseed directories",
"apt::cacher": "Set up an APT cache",
"apt::cacher-client": "Client for the apt::cacher server"
},
"version": "1.2.2"
}
2 changes: 1 addition & 1 deletion cookbooks/apt/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
license "Apache 2.0"
description "Configures apt and apt services and an LWRP for managing apt repositories"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.1.2"
version "1.2.2"
recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories"
recipe "apt::cacher", "Set up an APT cache"
recipe "apt::cacher-client", "Client for the apt::cacher server"
Expand Down
1 change: 1 addition & 0 deletions cookbooks/apt/providers/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
end.run_action(:create)
execute "update package index" do
command "apt-get update"
ignore_failure true
action :nothing
end.run_action(:run)
new_resource.updated_by_last_action(true)
Expand Down
32 changes: 28 additions & 4 deletions cookbooks/apt/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Cookbook Name:: apt
# Recipe:: default
#
# Copyright 2008-2009, Opscode, Inc.
# Copyright 2008-2011, Opscode, Inc.
# Copyright 2009, Bryan McLellan <btm@loftninjas.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,17 +18,40 @@
# limitations under the License.
#

e = execute "apt-get update" do
# Run apt-get update to create the stamp file
execute "apt-get-update" do
command "apt-get update"
ignore_failure true
not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end
action :nothing
end

e.run_action(:run)
# For other recipes to call to force an update
execute "apt-get update" do
command "apt-get update"
ignore_failure true
action :nothing
end

# provides /var/lib/apt/periodic/update-success-stamp on apt-get update
package "update-notifier-common" do
notifies :run, resources(:execute => "apt-get-update"), :immediately
end

execute "apt-get-update-periodic" do
command "apt-get update"
ignore_failure true
only_if do
File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
end
end

%w{/var/cache/local /var/cache/local/preseeding}.each do |dirname|
directory dirname do
owner "root"
group "root"
mode 0755
mode 0644
action :create
end
end

0 comments on commit 595d0e0

Please sign in to comment.