Skip to content
Browse files

update cookbooks

  • Loading branch information...
1 parent f0a1cc6 commit 2e1de355e8a3747da19f0239e01bb6ce569f4f8e @zhengjia committed
View
4 cookbooks/apt/.gitignore
@@ -0,0 +1,4 @@
+.bundle
+.cache
+.kitchen
+bin
View
75 cookbooks/apt/CHANGELOG.md
@@ -0,0 +1,75 @@
+## v1.9.0:
+
+* [COOK-2185] - Proxy for apt-key
+* [COOK-2338] - Support pinning by glob() or regexp
+
+## v1.8.4:
+
+* [COOK-2171] - Update README to clarify required Chef version: 10.18.0
+ or higher.
+
+## v1.8.2:
+
+* [COOK-2112] - need [] around "arch" in sources.list entries
+* [COOK-2171] - fixes a regression in the notification
+
+## v1.8.0:
+
+* [COOK-2143] - Allow for a custom cacher-ng port
+* [COOK-2171] - On `apt_repository.run_action(:add)` the source file
+ is not created.
+* [COOK-2184] - apt::cacher-ng, use `cacher_port` attribute in
+ acng.conf
+
+## v1.7.0:
+
+* [COOK-2082] - add "arch" parameter to apt_repository LWRP
+
+## v1.6.0:
+
+* [COOK-1893] - `apt_preference` use "`package_name`" resource instead of "name"
+* [COOK-1894] - change filename for sources.list.d files
+* [COOK-1914] - Wrong dir permissions for /etc/apt/preferences.d/
+* [COOK-1942] - README.md has wrong name for the keyserver attribute
+* [COOK-2019] - create 01proxy before any other apt-get updates get executed
+
+## v1.5.2:
+
+* [COOK-1682] - use template instead of file resource in apt::cacher-client
+* [COOK-1875] - cacher-client should be Environment-aware
+
+## V1.5.0:
+
+* [COOK-1500] - Avoid triggering apt-get update
+* [COOK-1548] - Add execute commands for autoclean and autoremove
+* [COOK-1591] - Setting up the apt proxy should leave https
+ connections direct
+* [COOK-1596] - execute[apt-get-update-periodic] never runs
+* [COOK-1762] - create /etc/apt/preferences.d directory
+* [COOK-1776] - apt key check isn't idempotent
+
+## v1.4.8:
+
+* Adds test-kitchen support
+* [COOK-1435] - repository lwrp is not idempotent with http key
+
+## v1.4.6:
+
+* [COOK-1530] - apt_repository isn't aware of update-success-stamp
+ file (also reverts COOK-1382 patch).
+
+## v1.4.4:
+
+* [COOK-1229] - Allow cacher IP to be set manually in non-Chef Solo
+ environments
+* [COOK-1530] - Immediately update apt-cache when sources.list file is dropped off
+
+## v1.4.2:
+
+* [COOK-1155] - LWRP for apt pinning
+
+## v1.4.0:
+
+* [COOK-889] - overwrite existing repo source files
+* [COOK-921] - optionally use cookbook\_file or remote\_file for key
+* [COOK-1032] - fixes problem with apt repository key installation
View
29 cookbooks/apt/CONTRIBUTING
@@ -0,0 +1,29 @@
+If you would like to contribute, please open a ticket in JIRA:
+
+* http://tickets.opscode.com
+
+Create the ticket in the COOK project and use the cookbook name as the
+component.
+
+For all code contributions, we ask that contributors sign a
+contributor license agreement (CLA). Instructions may be found here:
+
+* http://wiki.opscode.com/display/chef/How+to+Contribute
+
+When contributing changes to individual cookbooks, please do not
+modify the version number in the metadata.rb. Also please do not
+update the CHANGELOG.md for a new version. Not all changes to a
+cookbook may be merged and released in the same versions. Opscode will
+handle the version updates during the release process. You are welcome
+to correct typos or otherwise make updates to documentation in the
+README.
+
+If a contribution adds new platforms or platform versions, indicate
+such in the body of the commit message(s), and update the relevant
+COOK ticket. When writing commit messages, it is helpful for others if
+you indicate the COOK ticket. For example:
+
+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
+
+In the ticket itself, it is also helpful if you include log output of
+a successful Chef run, but this is not absolutely required.
View
3 cookbooks/apt/Gemfile
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem 'test-kitchen', '< 1.0'
View
201 cookbooks/apt/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
View
179 cookbooks/apt/README.md
@@ -1,20 +1,31 @@
Description
===========
-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.
+This cookbook includes recipes to execute apt-get update to ensure the
+local APT package cache is up to date. There are recipes for managing
+the apt-cacher-ng caching proxy and proxy clients. It also includes a
+LWRP for managing APT repositories in /etc/apt/sources.list.d as well as
+an LWRP for pinning packages via /etc/apt/preferences.d.
-Changes
-=======
+Requirements
+============
+
+Version 1.8.2+ of this cookbook requires **Chef 10.16.4** or later.
+
+If your Chef version is earlier than 10.16.4, use version 1.7.0 of
+this cookbook.
-## v1.2.2:
+See [CHEF-3493](http://tickets.opscode.com/browse/CHEF-3493) and
+[this code comment](http://bit.ly/VgvCgf) for more information on this
+requirement.
-* COOK-804: apt-get update resource in apt cookbook changed names
+Platform
+--------
-## v1.2.0:
+* Debian
+* Ubuntu
-* 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`
+May work with or without modification on other Debian derivatives.
Recipes
=======
@@ -22,25 +33,42 @@ Recipes
default
-------
-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 installs the `update-notifier-common` package to provide
+the timestamp file used to only run `apt-get update` if the cache is
+more 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 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
-------
+cacher-ng
+---------
-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.
+Installs the `apt-cacher-ng` package and service so the system can
+provide APT caching. You can check the usage report at
+http://{hostname}:3142/acng-report.html. The `cacher-ng` recipe
+includes the `cacher-client` recipe, so it helps seed itself.
cacher-client
-------------
-Configures the node to use the apt-cacher server as a client.
+Configures the node to use the `apt-cacher-ng` server as a client. If you
+want to restrict your node to using the `apt-cacher-ng` server in your
+Environment, set `['apt']['cacher-client']['restrict_environment']` to `true`.
+To use a cacher server (or standard proxy server) not available via search
+set the atttribute `['apt']['cacher-ipaddress']` and for a custom port
+set `['apt']['cacher_port']`
Resources/Providers
===================
-This LWRP provides an easy way to manage additional APT repositories. Adding a new repository will notify running the `execute[apt-get-update]` resource.
+Managing 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 immediately.
# Actions
@@ -51,22 +79,30 @@ This LWRP provides an easy way to manage additional APT repositories. Adding a n
- repo_name: name attribute. The name of the channel to discover
- uri: the base of the Debian distribution
-- distribution: this is usually your release's codename...ie something like `karmic`, `lucid` or `maverick`
+- distribution: this is usually your release's codename...ie something
+ like `karmic`, `lucid` or `maverick`
- components: package groupings..when it doubt use `main`
-- deb_src: whether or not to add the repository as a source repo as well
-- 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
+- arch: constrain package to a particular arch like `i386`, `amd64` or
+ even `armhf` or `powerpc`. Defaults to nil.
+- deb_src: whether or not to add the repository as a source repo as
+ well - value can be `true` or `false`, default `false`.
+- keyserver: the GPG keyserver where the key for the repo should be retrieved
+- key: if a `keyserver` is provided, this is assumed to be the
+ fingerprint, otherwise it can be either the URI to the GPG key for
+ the repo, or a cookbook_file.
+- key_proxy: if set, pass the specified proxy via `http-proxy=` to GPG.
+- cookbook: if key should be a cookbook_file, specify a cookbook where
+ the key is located for files/default. Defaults to nil, so it will
+ use the cookbook where the resource is used.
# Examples
# add the Zenoss repo
apt_repository "zenoss" do
uri "http://dev.zenoss.org/deb"
- distribution "main"
- components ["stable"]
- action :add
+ components ["main","stable"]
end
-
+
# add the Nginx PPA; grab key from keyserver
apt_repository "nginx-php" do
uri "http://ppa.launchpad.net/nginx/php5/ubuntu"
@@ -74,35 +110,111 @@ This LWRP provides an easy way to manage additional APT repositories. Adding a n
components ["main"]
keyserver "keyserver.ubuntu.com"
key "C300EE8C"
- action :add
end
-
+
+ # add the Nginx PPA; grab key from keyserver, also add source repo
+ apt_repository "nginx-php" do
+ uri "http://ppa.launchpad.net/nginx/php5/ubuntu"
+ distribution node['lsb']['codename']
+ components ["main"]
+ keyserver "keyserver.ubuntu.com"
+ key "C300EE8C"
+ deb_src true
+ end
+
# add the Cloudkick Repo
apt_repository "cloudkick" do
uri "http://packages.cloudkick.com/ubuntu"
distribution node['lsb']['codename']
components ["main"]
key "http://packages.cloudkick.com/cloudkick.packages.key"
- action :add
end
-
+
+ # add the Cloudkick Repo with the key downloaded in the cookbook
+ apt_repository "cloudkick" do
+ uri "http://packages.cloudkick.com/ubuntu"
+ distribution node['lsb']['codename']
+ components ["main"]
+ key "cloudkick.packages.key"
+ end
+
+ # add the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64
+ apt_repository "cloudera" do
+ uri "http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh"
+ arch "amd64"
+ distribution "precise-cdh4"
+ components ["contrib"]
+ key "http://archive.cloudera.com/debian/archive.key"
+ end
+
# remove Zenoss repo
apt_repository "zenoss" do
action :remove
end
-
+
+Pinning packages
+----------------
+
+This LWRP provides an easy way to pin packages in /etc/apt/preferences.d.
+Although apt-pinning is quite helpful from time to time please note that Debian
+does not encourage its use without thorough consideration.
+
+Further information regarding apt-pinning is available via
+http://wiki.debian.org/AptPreferences.
+
+# Actions
+
+- :add: creates a preferences file under /etc/apt/preferences.d
+- :remove: Removes the file, therefore unpin the package
+
+# Attribute Parameters
+
+- package_name: name attribute. The name of the package
+- glob: Pin by glob() expression or regexp surrounded by /.
+- pin: The package version/repository to pin
+- pin_priority: The pinning priority aka "the highest package version wins"
+
+# Examples
+
+ # Pin libmysqlclient16 to version 5.1.49-3
+ apt_preference "libmysqlclient16" do
+ pin "version 5.1.49-3"
+ pin_priority "700"
+ end
+
+ # Unpin libmysqlclient16
+ apt_preference "libmysqlclient16" do
+ action :remove
+ end
+
+ # Pin all packages from dotdeb.org
+ apt_preference "dotdeb" do
+ glob "*"
+ pin "origin packages.dotdeb.org "
+ pin_priority "700"
+ end
+
Usage
=====
-Put `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.:
+Put `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.:
template "/etc/apt/sources.list.d/my_apt_sources.list" do
notifies :run, resources(:execute => "apt-get update"), :immediately
end
-The 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.
+The 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.
-Put `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.
+Put `recipe[apt::cacher-ng]` 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.
+
+If you want to cleanup unused packages, there is also the `apt-get autoclean`
+and `apt-get autoremove` resources provided for automated cleanup.
License and Author
==================
@@ -111,7 +223,7 @@ Author:: Joshua Timberman (<joshua@opscode.com>)
Author:: Matt Ray (<matt@opscode.com>)
Author:: Seth Chisamore (<schisamo@opscode.com>)
-Copyright 2009-2011 Opscode, Inc.
+Copyright 2009-2012 Opscode, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -124,4 +236,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
View
3 cookbooks/apt/attributes/default.rb
@@ -0,0 +1,3 @@
+default['apt']['cacher-client']['restrict_environment'] = false
+default['apt']['cacher_port'] = 3142
+default['apt']['key_proxy'] = ''
View
9 cookbooks/apt/files/default/apt-cacher
@@ -1,9 +0,0 @@
-# apt-cacher startup configuration file
-
-# IMPORTANT: check the apt-cacher.conf file before using apt-cacher as daemon.
-
-# set to 1 to start the daemon at boot time
-AUTOSTART=1
-
-# extra settings to override the ones in apt-cacher.conf
-# EXTRAOPT=" daemon_port=3142 limit=30 "
View
144 cookbooks/apt/files/default/apt-cacher.conf
@@ -1,144 +0,0 @@
-# This file has been modified by ./apt-proxy-to-apt-cacher
-# Some lines may have been appended at the bottom of this file
-# This file has been modified by /usr/share/apt-cacher/apt-proxy-to-apt-cacher
-# Some lines may have been appended at the bottom of this file
-#################################################################
-# This is the config file for apt-cacher. On most Debian systems
-# you can safely leave the defaults alone.
-#################################################################
-
-# cache_dir is used to set the location of the local cache. This can
-# become quite large, so make sure it is somewhere with plenty of space.
-cache_dir=/var/cache/apt-cacher
-
-# The email address of the administrator is displayed in the info page
-# and traffic reports.
-admin_email=root@localhost
-
-# For the daemon startup settings please edit the file /etc/default/apt-cacher.
-
-# Daemon port setting, only useful in stand-alone mode. You need to run the
-# daemon as root to use privileged ports (<1024).
-daemon_port = 3142
-
-# optional settings, user and group to run the daemon as. Make sure they have
-# sufficient permissions on the cache and log directories. Comment the settings
-# to run apt-cacher as the native user.
-group=www-data
-user=www-data
-
-# optional setting, binds the listening daemon to one specified IP. Use IP
-# ranges for more advanced configuration, see below.
-# daemon_addr=localhost
-
-# If your apt-cacher machine is directly exposed to the Internet and you are
-# worried about unauthorised machines fetching packages through it, you can
-# specify a list of IPv4 addresses which are allowed to use it and another
-# list of IPv4 addresses which aren't.
-# Localhost (127.0.0.1) is always allowed. Other addresses must be matched
-# by allowed_hosts and not by denied_hosts to be permitted to use the cache.
-# Setting allowed_hosts to "*" means "allow all".
-# Otherwise the format is a comma-separated list containing addresses,
-# optionally with masks (like 10.0.0.0/22), or ranges of addresses (two
-# addresses separated by a hyphen, no masks, like '192.168.0.3-192.168.0.56').
-allowed_hosts=*
-denied_hosts=
-
-# And similiarly for IPv6 with allowed_hosts_6 and denied_hosts_6.
-# Note that IPv4-mapped IPv6 addresses (::ffff:w.x.y.z) are truncated to
-# w.x.y.z and are handled as IPv4.
-allowed_hosts_6=fec0::/16
-denied_hosts_6=
-
-# This thing can be done by Apache but is much simplier here - limit access to
-# Debian mirrors based on server names in the URLs
-#allowed_locations=ftp.uni-kl.de,ftp.nerim.net,debian.tu-bs.de
-
-# Apt-cacher can generate usage reports every 24 hours if you set this
-# directive to 1. You can view the reports in a web browser by pointing
-# to your cache machine with '/apt-cacher/report' on the end, like this:
-# http://yourcache.example.com/apt-cacher/report
-# Generating reports is very fast even with many thousands of logfile
-# lines, so you can safely turn this on without creating much
-# additional system load.
-generate_reports=1
-
-# Apt-cacher can clean up its cache directory every 24 hours if you set
-# this directive to 1. Cleaning the cache can take some time to run
-# (generally in the order of a few minutes) and removes all package
-# files that are not mentioned in any existing 'Packages' lists. This
-# has the effect of deleting packages that have been superseded by an
-# updated 'Packages' list.
-clean_cache=1
-
-# The directory to use for apt-cacher access and error logs.
-# The access log records every request in the format:
-# date-time|client ip address|HIT/MISS/EXPIRED|object size|object name
-# The error log is slightly more free-form, and is also used for debug
-# messages if debug mode is turned on.
-# Note that the old 'logfile' and 'errorfile' directives are
-# deprecated: if you set them explicitly they will be honoured, but it's
-# better to just get rid of them from old config files.
-logdir=/var/log/apt-cacher
-
-# apt-cacher can use different methods to decide whether package lists need to
-# be updated,
-# A) looking at the age of the cached files
-# B) getting HTTP header from server and comparing that with cached data. This
-# method is more reliable and avoids desynchronisation of data and index files
-# but needs to transfer few bytes from the server every time somebody requests
-# the files ("apt-get update")
-# Set the following value to the maximum age (in hours) for method A or to 0
-# for method B
-expire_hours=0
-
-# Apt-cacher can pass all its requests to an external http proxy like
-# Squid, which could be very useful if you are using an ISP that blocks
-# port 80 and requires all web traffic to go through its proxy. The
-# format is 'hostname:port', eg: 'proxy.example.com:8080'.
-http_proxy=proxy.example.com:8080
-
-# Use of an external proxy can be turned on or off with this flag.
-# Value should be either 0 (off) or 1 (on).
-use_proxy=0
-
-# External http proxy sometimes need authentication to get full access. The
-# format is 'username:password'.
-http_proxy_auth=proxyuser:proxypass
-
-# Use of external proxy authentication can be turned on or off with this flag.
-# Value should be either 0 (off) or 1 (on).
-use_proxy_auth=0
-
-# Rate limiting sets the maximum bandwidth in bytes per second to use
-# for fetching packages. Syntax is fully defined in 'man wget'.
-# Use 'k' or 'm' to use kilobits or megabits / second: eg, 'limit=25k'.
-# Use 0 or a negative value for no rate limiting.
-limit=0
-
-# Debug mode makes apt-cacher spew a lot of extra debug junk to the
-# error log (whose location is defined with the 'logdir' directive).
-# Leave this off unless you need it, or your error log will get very
-# big. Acceptable values are 0 or 1.
-debug=0
-
-# Adapt the line in the usage info web page to match your server configuration
-# example_sources_line=deb&nbsp;http://<b>my.cacher.server:3142/</b>ftp.au.debian.org/debian&nbsp;unstable&nbsp;main&nbsp;contrib&nbsp;non-free
-
-# Print a 410 (Gone) HTTP message with the specified text when accessed via
-# CGI. Useful to tell users to adapt their sources.list files when the
-# apt-cacher server is beeing relocated (via apt-get's error messages while
-# running "update")
-#cgi_advise_to_use = Please use http://cacheserver:3142/ as apt-cacher access URL
-#cgi_advise_to_use = Server relocated. To change sources.list, run perl -pe "s,/apt-cacher\??,:3142," -i /etc/apt/sources.list
-
-# Server mapping - this allows to hide real server names behind virtual paths
-# that appear in the access URL. This method is known from apt-proxy. This is
-# also the only method to use FTP access to the target hosts. The syntax is simple, the part of the beginning to replace, followed by a list of mirror urls, all space separated. Multiple profile are separated by semicolons
-# path_map = debian ftp.uni-kl.de/pub/linux/debian ftp2.de.debian.org/debian ; ubuntu archive.ubuntu.com/ubuntu ; security security.debian.org/debian-security ftp2.de.debian.org/debian-security
-# Note that you need to specify all target servers in the allowed_locations
-# options if you make use of it. Also note that the paths should not overlap
-# each other. FTP access method not supported yet, maybe in the future.
-
-# extra setting from apt-proxy configuration
-path_map = ubuntu us.archive.ubuntu.com/ubuntu ; ubuntu-security security.ubuntu.com/ubuntu ; debian debian.osuosl.org/debian/ ; security security.debian.org/debian-security
View
34 cookbooks/apt/metadata.json
@@ -0,0 +1,34 @@
+{
+ "name": "apt",
+ "description": "Configures apt and apt services and LWRPs for managing apt repositories and preferences",
+ "long_description": "Description\n===========\n\nThis cookbook includes recipes to execute apt-get update to ensure the\nlocal APT package cache is up to date. There are recipes for managing\nthe apt-cacher-ng caching proxy and proxy clients. It also includes a\nLWRP for managing APT repositories in /etc/apt/sources.list.d as well as\nan LWRP for pinning packages via /etc/apt/preferences.d.\n\nRequirements\n============\n\nVersion 1.8.2+ of this cookbook requires **Chef 10.16.4** or later.\n\nIf your Chef version is earlier than 10.16.4, use version 1.7.0 of\nthis cookbook.\n\nSee [CHEF-3493](http://tickets.opscode.com/browse/CHEF-3493) and\n[this code comment](http://bit.ly/VgvCgf) for more information on this\nrequirement.\n\nPlatform\n--------\n\n* Debian\n* Ubuntu\n\nMay work with or without modification on other Debian derivatives.\n\nRecipes\n=======\n\ndefault\n-------\n\nThis recipe installs the `update-notifier-common` package to provide\nthe timestamp file used to only run `apt-get update` if the cache is\nmore than one day old.\n\nThis recipe should appear first in the run list of Debian or Ubuntu\nnodes to ensure that the package cache is up to date before managing\nany `package` resources with Chef.\n\nThis recipe also sets up a local cache directory for preseeding packages.\n\ncacher-ng\n---------\n\nInstalls the `apt-cacher-ng` package and service so the system can\nprovide APT caching. You can check the usage report at\nhttp://{hostname}:3142/acng-report.html. The `cacher-ng` recipe\nincludes the `cacher-client` recipe, so it helps seed itself.\n\ncacher-client\n-------------\nConfigures the node to use the `apt-cacher-ng` server as a client. If you\nwant to restrict your node to using the `apt-cacher-ng` server in your\nEnvironment, set `['apt']['cacher-client']['restrict_environment']` to `true`.\nTo use a cacher server (or standard proxy server) not available via search\nset the atttribute `['apt']['cacher-ipaddress']` and for a custom port\nset `['apt']['cacher_port']`\n\nResources/Providers\n===================\n\nManaging repositories\n---------------------\n\nThis LWRP provides an easy way to manage additional APT repositories.\nAdding a new repository will notify running the `execute[apt-get-update]`\nresource immediately.\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\n like `karmic`, `lucid` or `maverick`\n- components: package groupings..when it doubt use `main`\n- arch: constrain package to a particular arch like `i386`, `amd64` or\n even `armhf` or `powerpc`. Defaults to nil.\n- deb_src: whether or not to add the repository as a source repo as\n well - value can be `true` or `false`, default `false`.\n- keyserver: the GPG keyserver where the key for the repo should be retrieved\n- key: if a `keyserver` is provided, this is assumed to be the\n fingerprint, otherwise it can be either the URI to the GPG key for\n the repo, or a cookbook_file.\n- key_proxy: if set, pass the specified proxy via `http-proxy=` to GPG.\n- cookbook: if key should be a cookbook_file, specify a cookbook where\n the key is located for files/default. Defaults to nil, so it will\n use the cookbook where the resource is used.\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 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 end\n\n # add the Nginx PPA; grab key from keyserver, also add source repo\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 deb_src true\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 end\n\n # add the Cloudkick Repo with the key downloaded in the cookbook\n apt_repository \"cloudkick\" do\n uri \"http://packages.cloudkick.com/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n key \"cloudkick.packages.key\"\n end\n\n # add the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64\n apt_repository \"cloudera\" do\n uri \"http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh\"\n arch \"amd64\"\n distribution \"precise-cdh4\"\n components [\"contrib\"]\n key \"http://archive.cloudera.com/debian/archive.key\"\n end\n\n # remove Zenoss repo\n apt_repository \"zenoss\" do\n action :remove\n end\n\nPinning packages\n----------------\n\nThis LWRP provides an easy way to pin packages in /etc/apt/preferences.d.\nAlthough apt-pinning is quite helpful from time to time please note that Debian\ndoes not encourage its use without thorough consideration.\n\nFurther information regarding apt-pinning is available via\nhttp://wiki.debian.org/AptPreferences.\n\n# Actions\n\n- :add: creates a preferences file under /etc/apt/preferences.d\n- :remove: Removes the file, therefore unpin the package\n\n# Attribute Parameters\n\n- package_name: name attribute. The name of the package\n- glob: Pin by glob() expression or regexp surrounded by /.\n- pin: The package version/repository to pin\n- pin_priority: The pinning priority aka \"the highest package version wins\"\n\n# Examples\n\n # Pin libmysqlclient16 to version 5.1.49-3\n apt_preference \"libmysqlclient16\" do\n pin \"version 5.1.49-3\"\n pin_priority \"700\"\n end\n\n # Unpin libmysqlclient16\n apt_preference \"libmysqlclient16\" do\n action :remove\n end\n\n # Pin all packages from dotdeb.org\n apt_preference \"dotdeb\" do\n glob \"*\"\n pin \"origin packages.dotdeb.org \"\n pin_priority \"700\"\n end\n\nUsage\n=====\n\nPut `recipe[apt]` first in the run list. If you have other recipes\nthat you want to use to configure how apt behaves, like new sources,\nnotify 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\ntemplate resource, and should appear before other package resources\nthat need the sources in the template.\n\nPut `recipe[apt::cacher-ng]` in the run_list for a server to provide\nAPT caching and add `recipe[apt::cacher-client]` on the rest of the\nDebian-based nodes to take advantage of the caching server.\n\nIf you want to cleanup unused packages, there is also the `apt-get autoclean`\nand `apt-get autoremove` resources provided for automated cleanup.\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-2012 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",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ "ubuntu": ">= 0.0.0",
+ "debian": ">= 0.0.0"
+ },
+ "dependencies": {
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "apt": "Runs apt-get update during compile phase and sets up preseed directories",
+ "apt::cacher-ng": "Set up an apt-cacher-ng caching proxy",
+ "apt::cacher-client": "Client for the apt::cacher-ng caching proxy"
+ },
+ "version": "1.9.0"
+}
View
9 cookbooks/apt/metadata.rb
@@ -1,12 +1,13 @@
+name "apt"
maintainer "Opscode, Inc."
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
-description "Configures apt and apt services and an LWRP for managing apt repositories"
+description "Configures apt and apt services and LWRPs for managing apt repositories and preferences"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version "1.2.2"
+version "1.9.0"
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"
+recipe "apt::cacher-ng", "Set up an apt-cacher-ng caching proxy"
+recipe "apt::cacher-client", "Client for the apt::cacher-ng caching proxy"
%w{ ubuntu debian }.each do |os|
supports os
View
61 cookbooks/apt/providers/preference.rb
@@ -0,0 +1,61 @@
+#
+# Cookbook Name:: apt
+# Provider:: preference
+#
+# Copyright 2010-2011, Opscode, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Build preferences.d file contents
+def build_pref(package_name, pin, pin_priority)
+ preference_content = "Package: #{package_name}\nPin: #{pin}\nPin-Priority: #{pin_priority}\n"
+end
+
+action :add do
+ new_resource.updated_by_last_action(false)
+
+ preference = build_pref(new_resource.glob || new_resource.package_name,
+ new_resource.pin,
+ new_resource.pin_priority)
+
+ preference_dir = directory "/etc/apt/preferences.d" do
+ owner "root"
+ group "root"
+ mode 00755
+ recursive true
+ action :nothing
+ end
+
+ preference_file = file "/etc/apt/preferences.d/#{new_resource.name}" do
+ owner "root"
+ group "root"
+ mode 00644
+ content preference
+ action :nothing
+ end
+
+ preference_dir.run_action(:create)
+ # write out the preference file, replace it if it already exists
+ preference_file.run_action(:create)
+end
+
+action :remove do
+ if ::File.exists?("/etc/apt/preferences.d/#{new_resource.name}")
+ Chef::Log.info "Un-pinning #{new_resource.name} from /etc/apt/preferences.d/"
+ file "/etc/apt/preferences.d/#{new_resource.name}" do
+ action :delete
+ end
+ new_resource.updated_by_last_action(true)
+ end
+end
View
140 cookbooks/apt/providers/repository.rb
@@ -17,54 +17,122 @@
# limitations under the License.
#
+def whyrun_supported?
+ true
+end
+
+# install apt key from keyserver
+def install_key_from_keyserver(key, keyserver)
+ execute "install-key #{key}" do
+ if !node['apt']['key_proxy'].empty?
+ command "apt-key adv --keyserver-options http-proxy=#{node['apt']['key_proxy']} --keyserver #{keyserver} --recv #{key}"
+ else
+ command "apt-key adv --keyserver #{keyserver} --recv #{key}"
+ end
+ action :run
+ not_if "apt-key list | grep #{key}"
+ end
+end
+
+# run command and extract gpg ids
+def extract_gpg_ids_from_cmd(cmd)
+ so = Mixlib::ShellOut.new(cmd)
+ so.run_command
+ so.stdout.split(/\n/).collect do |t|
+ if z = t.match(/^pub\s+\d+\w\/([0-9A-F]{8})/)
+ z[1]
+ end
+ end.compact
+end
+
+# install apt key from URI
+def install_key_from_uri(uri)
+ key_name = uri.split(/\//).last
+ cached_keyfile = "#{Chef::Config[:file_cache_path]}/#{key_name}"
+ if new_resource.key =~ /http/
+ remote_file cached_keyfile do
+ source new_resource.key
+ mode 00644
+ action :create
+ end
+ else
+ cookbook_file cached_keyfile do
+ source new_resource.key
+ cookbook new_resource.cookbook
+ mode 00644
+ action :create
+ end
+ end
+
+ execute "install-key #{key_name}" do
+ command "apt-key add #{cached_keyfile}"
+ action :run
+ not_if do
+ installed_ids = extract_gpg_ids_from_cmd("apt-key finger")
+ key_ids = extract_gpg_ids_from_cmd("gpg --with-fingerprint #{cached_keyfile}")
+ (installed_ids & key_ids).sort == key_ids.sort
+ end
+ end
+end
+
+# build repo file contents
+def build_repo(uri, distribution, components, arch, add_deb_src)
+ components = components.join(' ') if components.respond_to?(:join)
+ repo_info = "#{uri} #{distribution} #{components}\n"
+ repo_info = "[arch=#{arch}] #{repo_info}" if arch
+ repo = "deb #{repo_info}"
+ repo << "deb-src #{repo_info}" if add_deb_src
+ repo
+end
+
action :add do
- unless ::File.exists?("/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list")
- Chef::Log.info "Adding #{new_resource.repo_name} repository to /etc/apt/sources.list.d/#{new_resource.repo_name}-source.list"
+ new_resource.updated_by_last_action(false)
+ @repo_file = nil
+
+ recipe_eval do
# add key
if new_resource.keyserver && new_resource.key
- execute "install-key #{new_resource.key}" do
- command "apt-key adv --keyserver #{new_resource.keyserver} --recv #{new_resource.key}"
- action :nothing
- end.run_action(:run)
- elsif new_resource.key && (new_resource.key =~ /http/)
- key_name = new_resource.key.split(/\//).last
- remote_file "#{Chef::Config[:file_cache_path]}/#{key_name}" do
- source new_resource.key
- mode "0644"
- action :nothing
- end.run_action(:create_if_missing)
- execute "install-key #{key_name}" do
- command "apt-key add #{Chef::Config[:file_cache_path]}/#{key_name}"
- action :nothing
- end.run_action(:run)
+ install_key_from_keyserver(new_resource.key, new_resource.keyserver)
+ elsif new_resource.key
+ install_key_from_uri(new_resource.key)
end
- # build our listing
- repo_info = "#{new_resource.uri} #{new_resource.distribution} #{new_resource.components.join(" ")}"
- repository = "deb #{repo_info}\n"
- repository += "deb-src #{repo_info}\n" if new_resource.deb_src
- # write out the file, replace it if it already exists
- file "/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" do
- owner "root"
- group "root"
- mode 0644
- content repository + "\n"
+
+ file "/var/lib/apt/periodic/update-success-stamp" do
action :nothing
- end.run_action(:create)
- execute "update package index" do
- command "apt-get update"
+ end
+
+ execute "apt-get update" do
ignore_failure true
action :nothing
- end.run_action(:run)
- new_resource.updated_by_last_action(true)
+ end
+
+ # build repo file
+ repository = build_repo(new_resource.uri,
+ new_resource.distribution,
+ new_resource.components,
+ new_resource.arch,
+ new_resource.deb_src)
+
+ @repo_file = file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
+ owner "root"
+ group "root"
+ mode 00644
+ content repository
+ action :create
+ notifies :delete, "file[/var/lib/apt/periodic/update-success-stamp]", :immediately
+ notifies :run, "execute[apt-get update]", :immediately if new_resource.cache_rebuild
+ end
end
+
+ raise RuntimeError, "The repository file to create is nil, cannot continue." if @repo_file.nil?
+ new_resource.updated_by_last_action(@repo_file.updated?)
end
action :remove do
- if ::File.exists?("/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list")
- Chef::Log.info "Removing #{new_resource.repo_name} repository from /etc/apt/sources.list.d/"
- file "/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" do
+ if ::File.exists?("/etc/apt/sources.list.d/#{new_resource.name}.list")
+ Chef::Log.info "Removing #{new_resource.name} repository from /etc/apt/sources.list.d/"
+ file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
action :delete
end
- new_resource.updated_by_last_action(true)
end
end
View
45 cookbooks/apt/recipes/cacher-client.rb
@@ -2,7 +2,7 @@
# Cookbook Name:: apt
# Recipe:: cacher-client
#
-# Copyright 2011, Opscode, Inc.
+# Copyright 2011, 2012 Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,26 +19,41 @@
#remove Acquire::http::Proxy lines from /etc/apt/apt.conf since we use 01proxy
#these are leftover from preseed installs
-execute "Remove proxy from /etc/apt/apt.conf" do
+execute 'Remove proxy from /etc/apt/apt.conf' do
command "sed --in-place '/^Acquire::http::Proxy/d' /etc/apt/apt.conf"
only_if "grep Acquire::http::Proxy /etc/apt/apt.conf"
end
-servers = search(:node, 'recipes:apt\:\:cacher') || []
+servers = []
+if node['apt'] && node['apt']['cacher_ipaddress']
+ cacher = Chef::Node.new
+ cacher.name(node['apt']['cacher_ipaddress'])
+ cacher.ipaddress(node['apt']['cacher_ipaddress'])
+ servers << cacher
+end
+
+unless Chef::Config[:solo]
+ query = 'recipes:apt\:\:cacher-ng'
+ query += " AND chef_environment:#{node.chef_environment}" if node['apt']['cacher-client']['restrict_environment']
+ Chef::Log.debug("apt::cacher-client searching for '#{query}'")
+ servers += search(:node, query)
+end
+
if servers.length > 0
- Chef::Log.info("apt-cacher server found on #{servers[0]}.")
- proxy = "Acquire::http::Proxy \"http://#{servers[0].ipaddress}:3142\";\n"
- file "/etc/apt/apt.conf.d/01proxy" do
- owner "root"
- group "root"
- mode "0644"
- content proxy
- action :create
- end
+ Chef::Log.info("apt-cacher-ng server found on #{servers[0]}.")
+ template '/etc/apt/apt.conf.d/01proxy' do
+ source '01proxy.erb'
+ owner 'root'
+ group 'root'
+ mode 00644
+ variables(
+ :proxy => servers[0]['ipaddress'],
+ :port => node['apt']['cacher_port']
+ )
+ end.run_action(:create)
else
- Chef::Log.info("No apt-cacher server found.")
- file "/etc/apt/apt.conf.d/01proxy" do
+ Chef::Log.info('No apt-cacher-ng server found.')
+ file '/etc/apt/apt.conf.d/01proxy' do
action :delete
- only_if {File.exists?("/etc/apt/apt.conf.d/01proxy")}
end
end
View
28 cookbooks/apt/recipes/cacher.rb → cookbooks/apt/recipes/cacher-ng.rb
@@ -1,8 +1,8 @@
#
# Cookbook Name:: apt
-# Recipe:: cacher
+# Recipe:: cacher-ng
#
-# Copyright 2008-2011, Opscode, Inc.
+# Copyright 2008-2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,29 +16,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-package "apt-cacher" do
+
+package "apt-cacher-ng" do
action :install
end
-service "apt-cacher" do
+service "apt-cacher-ng" do
supports :restart => true, :status => false
- action [ :enable, :start ]
+ action :enable
end
-cookbook_file "/etc/apt-cacher/apt-cacher.conf" do
- source "apt-cacher.conf"
+template "/etc/apt-cacher-ng/acng.conf" do
+ source "acng.conf.erb"
owner "root"
group "root"
- mode 0644
- notifies :restart, resources(:service => "apt-cacher")
+ mode 00644
+ notifies :restart, "service[apt-cacher-ng]"
end
-cookbook_file "/etc/default/apt-cacher" do
- source "apt-cacher"
- owner "root"
- group "root"
- mode 0644
- notifies :restart, resources(:service => "apt-cacher")
+# Reopen resource w/ start in case config issue causes startup to fail
+service "apt-cacher-ng" do
+ action :start
end
#this will help seed the proxy
View
19 cookbooks/apt/recipes/default.rb
@@ -23,7 +23,6 @@
command "apt-get update"
ignore_failure true
not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end
- action :nothing
end
# For other recipes to call to force an update
@@ -33,6 +32,18 @@
action :nothing
end
+# Automatically remove packages that are no longer needed for dependencies
+execute "apt-get autoremove" do
+ command "apt-get -y autoremove"
+ action :nothing
+end
+
+# Automatically remove .deb files for packages no longer on your system
+execute "apt-get autoclean" do
+ command "apt-get -y autoclean"
+ 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
@@ -42,8 +53,8 @@
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
+ ::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
+ ::File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
end
end
@@ -51,7 +62,7 @@
directory dirname do
owner "root"
group "root"
- mode 0644
+ mode 00755
action :create
end
end
View
30 cookbooks/apt/resources/preference.rb
@@ -0,0 +1,30 @@
+#
+# Cookbook Name:: apt
+# Resource:: preference
+#
+# Copyright 2010-2011, Opscode, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+actions :add, :remove
+
+def initialize(*args)
+ super
+ @action = :add
+end
+
+attribute :package_name, :kind_of => String, :name_attribute => true
+attribute :glob, :kind_of => String
+attribute :pin, :kind_of => String
+attribute :pin_priority, :kind_of => String
View
10 cookbooks/apt/resources/repository.rb
@@ -19,12 +19,22 @@
actions :add, :remove
+def initialize(*args)
+ super
+ @action = :add
+end
+
#name of the repo, used for source.list filename
attribute :repo_name, :kind_of => String, :name_attribute => true
attribute :uri, :kind_of => String
attribute :distribution, :kind_of => String
attribute :components, :kind_of => Array, :default => []
+attribute :arch, :kind_of => String, :default => nil
#whether or not to add the repository as a source repo as well
attribute :deb_src, :default => false
attribute :keyserver, :kind_of => String, :default => nil
attribute :key, :kind_of => String, :default => nil
+attribute :cookbook, :kind_of => String, :default => nil
+#trigger cache rebuild
+#If not you can trigger in the recipe itself after checking the status of resource.updated{_by_last_action}?
+attribute :cache_rebuild, :kind_of => [TrueClass, FalseClass], :default => true
View
2 cookbooks/apt/templates/default/01proxy.erb
@@ -0,0 +1,2 @@
+Acquire::http::Proxy "http://<%= @proxy %>:<%= @port %>";
+Acquire::https::Proxy "DIRECT";
View
276 cookbooks/apt/templates/default/acng.conf.erb
@@ -0,0 +1,276 @@
+
+# Letter case in directive names does not matter. Must be separated with colons.
+# Valid boolean values are a zero number for false, non-zero numbers for true.
+
+CacheDir: /var/cache/apt-cacher-ng
+
+# set empty to disable logging
+LogDir: /var/log/apt-cacher-ng
+
+# place to look for additional configuration and resource files if they are not
+# found in the configuration directory
+# SupportDir: /usr/lib/apt-cacher-ng
+
+# TCP (http) port
+# Set to 9999 to emulate apt-proxy
+Port:<%= node['apt']['cacher_port'] %>
+
+# Addresses or hostnames to listen on. Multiple addresses must be separated by
+# spaces. Each entry must be an exact local address which is associated with a
+# local interface. DNS resolution is performed using getaddrinfo(3) for all
+# available protocols (IPv4, IPv6, ...). Using a protocol specific format will
+# create binding(s) only on protocol specific socket(s) (e.g. 0.0.0.0 will listen
+# only to IPv4).
+#
+# Default: not set, will listen on all interfaces and protocols
+#
+# BindAddress: localhost 192.168.7.254 publicNameOnMainInterface
+
+# The specification of another proxy which shall be used for downloads.
+# Username and password are, and see manual for limitations.
+#
+#Proxy: http://www-proxy.example.net:80
+#proxy: username:proxypassword@proxy.example.net:3128
+
+# Repository remapping. See manual for details.
+# In this example, some backends files might be generated during package
+# installation using information collected on the system.
+Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian # Debian Archives
+Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu # Ubuntu Archives
+Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol # Debian Volatile Archives
+Remap-cygwin: file:cygwin_mirrors /cygwin # ; file:backends_cygwin # incomplete, please create this file or specify preferred mirrors here
+Remap-sfnet: file:sfnet_mirrors # ; file:backends_sfnet # incomplete, please create this file or specify preferred mirrors here
+Remap-alxrep: file:archlx_mirrors /archlinux # ; file:backend_archlx # Arch Linux
+Remap-fedora: file:fedora_mirrors # Fedora Linux
+Remap-epel: file:epel_mirrors # Fedora EPEL
+Remap-slrep: file:sl_mirrors # Scientific Linux
+
+# This is usually not needed for security.debian.org because it's always the
+# same DNS hostname. However, it might be enabled in order to use hooks,
+# ForceManaged mode or special flags in this context.
+# Remap-secdeb: security.debian.org
+
+# Virtual page accessible in a web browser to see statistics and status
+# information, i.e. under http://localhost:3142/acng-report.html
+ReportPage: acng-report.html
+
+# Socket file for accessing through local UNIX socket instead of TCP/IP. Can be
+# used with inetd bridge or cron client.
+# SocketPath:/var/run/apt-cacher-ng/socket
+
+# Forces log file to be written to disk after every line when set to 1. Default
+# is 0, buffers are flushed when the client disconnects.
+#
+# (technically, alias to the Debug option, see its documentation for details)
+#
+# UnbufferLogs: 0
+
+# Set to 0 to store only type, time and transfer sizes.
+# 1 -> client IP and relative local path are logged too
+# VerboseLog: 1
+
+# Don't detach from the console
+# ForeGround: 0
+
+# Store the pid of the daemon process therein
+# PidFile: /var/run/apt-cacher-ng/pid
+
+# Forbid outgoing connections, work around them or respond with 503 error
+# offlinemode:0
+
+# Forbid all downloads that don't run through preconfigured backends (.where)
+#ForceManaged: 0
+
+# Days before considering an unreferenced file expired (to be deleted).
+# Warning: if the value is set too low and particular index files are not
+# available for some days (mirror downtime) there is a risk of deletion of
+# still useful package files.
+ExTreshold: 4
+
+# Stop expiration when a critical problem appeared. Currently only failed
+# refresh of an index file is considered as critical.
+#
+# WARNING: don't touch this option or set to zero.
+# Anything else is DANGEROUS and may cause data loss.
+#
+# ExAbortOnProblems: 1
+
+# Replace some Windows/DOS-FS incompatible chars when storing
+# StupidFs: 0
+
+# Experimental feature for apt-listbugs: pass-through SOAP requests and
+# responses to/from bugs.debian.org. If not set, default is true if
+# ForceManaged is enabled and false otherwise.
+# ForwardBtsSoap: 1
+
+# The daemon has a small cache for DNS data, to speed up resolution. The
+# expiration time of the DNS entries can be configured in seconds.
+# DnsCacheSeconds: 3600
+
+# Don't touch the following values without good consideration!
+#
+# Max. count of connection threads kept ready (for faster response in the
+# future). Should be a sane value between 0 and average number of connections,
+# and depend on the amount of spare RAM.
+# MaxStandbyConThreads: 8
+#
+# Hard limit of active thread count for incoming connections, i.e. operation
+# is refused when this value is reached (below zero = unlimited).
+# MaxConThreads: -1
+#
+# Pigeonholing files with regular expressions (static/volatile). Can be
+# overriden here but not should not be done permanently because future update
+# of default settings would not be applied later.
+# VfilePattern = (^|.*?/)(Index|Packages(\.gz|\.bz2|\.lzma|\.xz)?|InRelease|Release|Release\.gpg|Sources(\.gz|\.bz2|\.lzma|\.xz)?|release|index\.db-.*\.gz|Contents-[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|((setup|setup-legacy)(\.ini|\.bz2|\.hint)(\.sig)?)|mirrors\.lst|repo(index|md)\.xml(\.asc|\.key)?|directory\.yast|products|content(\.asc|\.key)?|media|filelists\.xml\.gz|filelists\.sqlite\.bz2|repomd\.xml|packages\.[a-zA-Z][a-zA-Z]\.gz|info\.txt|license\.tar\.gz|license\.zip|.*\.db(\.tar\.gz)?|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|metalink\?repo|.*prestodelta\.xml\.gz)$|/dists/.*/installer-[^/]+/[^0-9][^/]+/images/.*
+# PfilePattern = .*(\.d?deb|\.rpm|\.dsc|\.tar(\.gz|\.bz2|\.lzma|\.xz)(\.gpg)?|\.diff(\.gz|\.bz2|\.lzma|\.xz)|\.jigdo|\.template|changelog|copyright|\.udeb|\.debdelta|\.diff/.*\.gz|(Devel)?ReleaseAnnouncement(\?.*)?|[a-f0-9]+-(susedata|updateinfo|primary|deltainfo).xml.gz|fonts/(final/)?[a-z]+32.exe(\?download.*)?|/dists/.*/installer-[^/]+/[0-9][^/]+/images/.*)$
+# Whitelist for expiration, file types not to be removed even when being
+# unreferenced. Default: many parts from VfilePattern where no parent index
+# exists or might be unknown.
+# WfilePattern = (^|.*?/)(Release|InRelease|Release\.gpg|(Packages|Sources)(\.gz|\.bz2|\.lzma|\.xz)?|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|.*\.xml|.*\.db\.tar\.gz|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|[a-z]+32.exe)$|/dists/.*/installer-.*/images/.*
+
+# Higher modes only working with the debug version
+# Warning, writes a lot into apt-cacher.err logfile
+# Value overwrites UnbufferLogs setting (aliased)
+# Debug:3
+
+# Usually, general purpose proxies like Squid expose the IP address of the
+# client user to the remote server using the X-Forwarded-For HTTP header. This
+# behaviour can be optionally turned on with the Expose-Origin option.
+# ExposeOrigin: 0
+
+# When logging the originating IP address, trust the information supplied by
+# the client in the X-Forwarded-For header.
+# LogSubmittedOrigin: 0
+
+# The version string reported to the peer, to be displayed as HTTP client (and
+# version) in the logs of the mirror.
+# WARNING: some archives use this header to detect/guess capabilities of the
+# client (i.e. redirection support) and change the behaviour accordingly, while
+# ACNG might not support the expected features. Expect side effects.
+#
+# UserAgent: Yet Another HTTP Client/1.2.3p4
+
+# In some cases the Import and Expiration tasks might create fresh volatile
+# data for internal use by reconstructing them using patch files. This
+# by-product might be recompressed with bzip2 and with some luck the resulting
+# file becomes identical to the *.bz2 file on the server, usable for APT
+# clients trying to fetch the full .bz2 compressed version. Injection of the
+# generated files into the cache has however a disadvantage on underpowered
+# servers: bzip2 compression can create high load on the server system and the
+# visible download of the busy .bz2 files also becomes slower.
+#
+# RecompBz2: 0
+
+# Network timeout for outgoing connections.
+# NetworkTimeout: 60
+
+# Sometimes it makes sense to not store the data in cache and just return the
+# package data to client as it comes in. DontCache parameters can enable this
+# behaviour for certain URL types. The tokens are extended regular expressions
+# that URLs are matched against.
+#
+# DontCacheRequested is applied to the URL as it comes in from the client.
+# Example: exclude packages built with kernel-package for x86
+# DontCacheRequested: linux-.*_10\...\.Custo._i386
+# Example usecase: exclude popular private IP ranges from caching
+# DontCacheRequested: 192.168.0 ^10\..* 172.30
+#
+# DontCacheResolved is applied to URLs after mapping to the target server. If
+# multiple backend servers are specified then it's only matched against the
+# download link for the FIRST possible source (due to implementation limits).
+# Example usecase: all Ubuntu stuff comes from a local mirror (specified as
+# backend), don't cache it again:
+# DontCacheResolved: ubuntumirror.local.net
+#
+# DontCache directive sets (overrides) both, DontCacheResolved and
+# DontCacheRequested. Provided for convenience, see those directives for
+# details.
+#
+# Default permission set of freshly created files and directories, as octal
+# numbers (see chmod(1) for details).
+# Can by limited by the umask value (see umask(2) for details) if it's set in
+# the environment of the starting shell, e.g. in apt-cacher-ng init script or
+# in its configuration file.
+# DirPerms: 00755
+# FilePerms: 00664
+#
+#
+# It's possible to use use apt-cacher-ng as a regular web server with limited
+# feature set, i.e.
+# including directory browsing and download of any file;
+# excluding sorting, mime types/encodings, CGI execution, index page
+# redirection and other funny things.
+# To get this behavior, mappings between virtual directories and real
+# directories on the server must be defined with the LocalDirs directive.
+# Virtual and real dirs are separated by spaces, multiple pairs are separated
+# by semi-colons. Real directories must be absolute paths.
+# NOTE: Since the names of that key directories share the same namespace as
+# repository names (see Remap-...) it's administrators job to avoid such
+# collisions on them (unless created deliberately).
+#
+# LocalDirs: woo /data/debarchive/woody ; hamm /data/debarchive/hamm
+
+# Precache a set of files referenced by specified index files. This can be used
+# to create a partial mirror usable for offline work. There are certain limits
+# and restrictions on the path specification, see manual for details. A list of
+# (maybe) relevant index files could be retrieved via
+# "apt-get --print-uris update" on a client machine.
+#
+# PrecacheFor: debrep/dists/unstable/*/source/Sources* debrep/dists/unstable/*/binary-amd64/Packages*
+
+# Arbitrary set of data to append to request headers sent over the wire. Should
+# be a well formated HTTP headers part including newlines (DOS style) which
+# can be entered as escape sequences (\r\n).
+# RequestAppendix: X-Tracking-Choice: do-not-track\r\n
+
+# Specifies the IP protocol families to use for remote connections. Order does
+# matter, first specified are considered first. Possible combinations:
+# v6 v4
+# v4 v6
+# v6
+# v4
+# (empty or not set: use system default)
+#
+# ConnectProto: v6 v4
+
+# Regular expiration algorithm finds package files which are no longer listed
+# in any index file and removes them of them after a safety period.
+# This option allows to keep more versions of a package in the cache after
+# safety period is over.
+# KeepExtraVersions: 1
+
+# Optionally uses TCP access control provided by libwrap, see hosts_access(5)
+# for details. Daemon name is apt-cacher-ng. Default if not set: decided on
+# startup by looking for explicit mentioning of apt-cacher-ng in
+# /etc/hosts.allow or /etc/hosts.deny files.
+# UseWrap: 0
+
+# If many machines from the same local network attempt to update index files
+# (apt-get update) at nearly the same time, the known state of these index file
+# is temporarily frozen and multiple requests receive the cached response
+# without contacting the server. This parameter (in seconds) specifies the
+# length of this period before the files are considered outdated.
+# Setting it too low transfers more data and increases remote server load,
+# setting it too high (more than a couple of minutes) increases the risk of
+# delivering inconsistent responses to the clients.
+# FreshIndexMaxAge: 27
+
+# Usually the users are not allowed to specify custom TCP ports of remote
+# mirrors in the requests, only the default HTTP port can be used (instead,
+# proxy administrator can create Remap- rules with custom ports). This
+# restriction can be disabled by specifying a list of allowed ports or 0 for
+# any port.
+#
+# AllowUserPorts: 80
+
+# Normally the HTTP redirection responses are forwarded to the original caller
+# (i.e. APT) which starts a new download attempt from the new URL. This
+# solution is ok for client configurations with proxy mode but doesn't work
+# well with configurations using URL prefixes. To work around this the server
+# can restart its own download with another URL. However, this might be used to
+# circumvent download source policies by malicious users.
+# The RedirMax option specifies how many such redirects the server should
+# follow per request, 0 disables the internal redirection. If not set,
+# default value is 0 if ForceManaged is used and 5 otherwise.
+#
+# RedirMax: 5
View
4 cookbooks/build-essential/.gitignore
@@ -0,0 +1,4 @@
+.bundle
+.cache
+.kitchen
+bin
View
35 cookbooks/build-essential/CHANGELOG.md
@@ -0,0 +1,35 @@
+## v1.3.4:
+
+* [COOK-2272] - Complete `platform_family` conversion in build-essential
+
+## v1.3.2:
+
+* [COOK-2069] - build-essential will install osx-gcc-installer when
+ Xcode is present
+
+## v1.3.0:
+
+ * [COOK-1895] - support smartos
+
+## v1.2.0:
+
+* Add test-kitchen support (source repo only)
+* [COOK-1677] - build-essential cookbook support for OpenSuse and SLES
+* [COOK-1718] - build-essential cookbook metadata should include scientific
+* [COOK-1768] - The apt-get update in build-essentials needs to be renamed
+
+## v1.1.2:
+
+* [COOK-1620] - support OS X 10.8
+
+## v1.1.0:
+
+* [COOK-1098] - support amazon linux
+* [COOK-1149] - support Mac OS X
+* [COOK-1296] - allow for compile-time installation of packages
+ through an attribute (see README)
+
+## v1.0.2:
+
+* [COOK-1098] - Add Amazon Linux platform support
+* [COOK-1149] - Add OS X platform support
View
29 cookbooks/build-essential/CONTRIBUTING
@@ -0,0 +1,29 @@
+If you would like to contribute, please open a ticket in JIRA:
+
+* http://tickets.opscode.com
+
+Create the ticket in the COOK project and use the cookbook name as the
+component.
+
+For all code contributions, we ask that contributors sign a
+contributor license agreement (CLA). Instructions may be found here:
+
+* http://wiki.opscode.com/display/chef/How+to+Contribute
+
+When contributing changes to individual cookbooks, please do not
+modify the version number in the metadata.rb. Also please do not
+update the CHANGELOG.md for a new version. Not all changes to a
+cookbook may be merged and released in the same versions. Opscode will
+handle the version updates during the release process. You are welcome
+to correct typos or otherwise make updates to documentation in the
+README.
+
+If a contribution adds new platforms or platform versions, indicate
+such in the body of the commit message(s), and update the relevant
+COOK ticket. When writing commit messages, it is helpful for others if
+you indicate the COOK ticket. For example:
+
+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
+
+In the ticket itself, it is also helpful if you include log output of
+a successful Chef run, but this is not absolutely required.
View
3 cookbooks/build-essential/Gemfile
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem 'test-kitchen', '<= 1.0'
View
201 cookbooks/build-essential/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
View
115 cookbooks/build-essential/README.md
@@ -1,15 +1,122 @@
-DESCRIPTION
+Description
===========
-Installs packages required for compiling C software from source.
+Installs packages required for compiling C software from source. Use
+this cookbook if you wish to compile C programs, or install RubyGems
+with native extensions.
-LICENSE AND AUTHOR
+Requirements
+============
+
+Chef version 0.10.10+ and Ohai 0.6.12+ are required.
+
+## Platform
+
+Supported platforms by platform family:
+
+* Linux (fedora redhat centos ubuntu debian amazon scientific)
+* Darwin (`mac_os_x` 10.6+)
+* SmartOs
+
+## Cookbooks
+
+Requires `pkgin` cookbook on SmartOS
+
+Attributes
+==========
+
+* `node['build_essential']['compiletime']` - Whether the resources in
+the default recipe should be configured at the "Compile" phase of the
+Chef run. Defaults to false, see __Usage__ for more information.
+* `node['build_essential']['osx']['gcc_installer_url']` - The URL of
+ the OS X GCC package installer (.pkg).
+* `node['build_essential']['osx']['gcc_installer_checksum']` - The
+ SHA256 checksum of the OS X GCC installer.
+
+Recipes
+=======
+
+This cookbook has one recipe, default.
+
+On Linux platforms (see __Platform__ above for a supported list of
+families), packages required to build C source projects are installed.
+This includes GCC, make, autconf and others. On Debian-family
+distributions, the apt-cache may need to be updated, especially during
+compile time installation. See __Usage__ for further information.
+
+On Mac OS X, the GCC standalone installer by Kenneth Reitz is
+installed. Note that this is *not* the Xcode CLI package, as that does
+not include all programs and headers required to build some common
+GNU-style C projects, such as those that are available from projects
+such as MacPorts or Homebrew. Changing the attributes for the GCC
+installer URL and checksum to the Xcode values may work, but this is
+untested.
+
+Usage
+=====
+
+Simply include the `build-essential` and the required tools will be
+installed to the system, and later recipes will be able to compile
+software from C source code.
+
+For RubyGems that include native C extensions you wish to use with
+Chef, you should do two things.
+
+0. Ensure that the C libraries, include files and other assorted "dev"
+type packages are installed. You should do this in the compile phase
+after the build-essential recipe.
+1. Use the `chef_gem` resource in your recipes. This requires Chef version 0.10.10+.
+2. Set the `compiletime` attribute in roles where such recipes are
+required. This will ensure that the build tools are available to
+compile the RubyGems' extensions, as `chef_gem` happens during the
+compile phase, too.
+
+Example installation of a devel package at compile-time in a recipe:
+
+ package "mypackage-dev" do
+ action :nothing
+ end.run_action(:install)
+
+Example use of `chef_gem`:
+
+ chef_gem "mygem"
+
+Example role:
+
+ name "myapp"
+ run_list(
+ "recipe[build-essential]",
+ "recipe[myapp]"
+ )
+ default_attributes(
+ "build_essential" => {
+ "compiletime" => true
+ }
+ )
+
+The compile time option (via the attribute) is to ensure that the
+proper packages are available at the right time in the Chef run. It is
+recommended that the build-essential recipe appear early in the run
+list.
+
+The Chef wiki has documentation on
+[the anatomy of a chef run](http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run).
+
+Limitations
+===========
+
+It is not in the scope of this cookbook to handle installing the
+required headers for individual software projects in order to compile
+them, or to compile RubyGems with native C extensions. You should
+create a cookbook for handling that.
+
+License and Author
==================
Author:: Joshua Timberman (<joshua@opscode.com>)
Author:: Seth Chisamore (<schisamo@opscode.com>)
-Copyright 2009-2011, Opscode, Inc.
+Copyright 2009-2011, Opscode, Inc. (<legal@opscode.com>)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
View
33 cookbooks/build-essential/attributes/default.rb
@@ -0,0 +1,33 @@
+#
+# Cookbook Name:: build-essential
+# Attributes:: default
+#
+# Copyright 2008-2012, Opscode, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+default['build_essential']['compiletime'] = false
+
+case node['platform_family']
+when "mac_os_x"
+ case
+ when Chef::VersionConstraint.new("~> 10.7.0").include?(node['platform_version']),
+ Chef::VersionConstraint.new("~> 10.8.0").include?(node['platform_version'])
+ default['build_essential']['osx']['gcc_installer_url'] = "https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg"
+ default['build_essential']['osx']['gcc_installer_checksum'] = "df36aa87606feb99d0db9ac9a492819e"
+ when Chef::VersionConstraint.new("~> 10.6.0").include?(node['platform_version'])
+ default['build_essential']['osx']['gcc_installer_url'] = "https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg"
+ default['build_essential']['osx']['gcc_installer_checksum'] = "d1db5bab6a3f6b9f3b5577a130baeefa"
+ end
+end
View
43 cookbooks/build-essential/metadata.json
@@ -0,0 +1,43 @@
+{
+ "name": "build-essential",
+ "description": "Installs C compiler / build tools",
+ "long_description": "",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ "fedora": ">= 0.0.0",
+ "redhat": ">= 0.0.0",
+ "centos": ">= 0.0.0",
+ "ubuntu": ">= 0.0.0",
+ "debian": ">= 0.0.0",
+ "amazon": ">= 0.0.0",
+ "suse": ">= 0.0.0",
+ "scientific": ">= 0.0.0",
+ "oracle": ">= 0.0.0",
+ "smartos": ">= 0.0.0",
+ "mac_os_x": ">= 10.6.0",
+ "mac_os_x_server": ">= 10.6.0"
+ },
+ "dependencies": {
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ "pkgin": ">= 0.0.0"
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "build-essential": "Installs packages required for compiling C software from source."
+ },
+ "version": "1.3.4"
+}
View
11 cookbooks/build-essential/metadata.rb
@@ -1,10 +1,15 @@
+name "build-essential"
maintainer "Opscode, Inc."
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs C compiler / build tools"
-version "1.0.0"
-recipe "build-essential", "Installs C compiler and build tools on Linux"
+version "1.3.4"
+recipe "build-essential", "Installs packages required for compiling C software from source."
-%w{ fedora redhat centos ubuntu debian }.each do |os|
+%w{ fedora redhat centos ubuntu debian amazon suse scientific oracle smartos}.each do |os|
supports os
end
+
+supports "mac_os_x", ">= 10.6.0"
+supports "mac_os_x_server", ">= 10.6.0"
+suggests "pkgin"
View
83 cookbooks/build-essential/recipes/default.rb
@@ -17,29 +17,76 @@
# limitations under the License.
#
-case node['platform']
-when "ubuntu","debian"
- %w{build-essential binutils-doc}.each do |pkg|
- package pkg do
- action :install
+require 'chef/shell_out'
+
+compiletime = node['build_essential']['compiletime']
+
+case node['platform_family']
+when "rhel", "suse", "fedora", "debian"
+
+ # on apt-based platforms when first provisioning we need to force
+ # apt-get update at compiletime if we are going to try to install at compiletime
+ if node['platform_family'] == "debian"
+ execute "apt-get-update-build-essentials" do
+ command "apt-get update"
+ action :nothing
+ # tip: to suppress this running every time, just use the apt cookbook
+ not_if do
+ ::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
+ ::File.mtime('/var/lib/apt/periodic/update-success-stamp') > Time.now - 86400*2
+ end
+ end.run_action(:run) if compiletime
+ end
+
+ packages = case node['platform_family']
+ when "debian"
+ %w{build-essential binutils-doc}
+ when "rhel", "fedora"
+ %w{gcc gcc-c++ kernel-devel make}
+ when "suse"
+ %w{gcc gcc-c++ kernel-default-devel make m4} # in SLES there is no kernel-devel
+ end
+
+ packages.each do |pkg|
+ r = package pkg do
+ action ( compiletime ? :nothing : :install )
end
+ r.run_action(:install) if compiletime
end
-when "centos","redhat","fedora"
- %w{gcc gcc-c++ kernel-devel make}.each do |pkg|
- package pkg do
- action :install
+
+ %w{autoconf flex bison}.each do |pkg|
+ r = package pkg do
+ action ( compiletime ? :nothing : :install )
end
+ r.run_action(:install) if compiletime
end
-end
-package "autoconf" do
- action :install
-end
+when "smartos"
+ include_recipe 'pkgin'
+ %w{gcc47 gcc47-runtime scmgit-base gmake pkg-config binutils}.each do |package|
+ pkgin_package package do
+ action :install
+ end
+ end
-package "flex" do
- action :install
-end
+when "mac_os_x"
+ result = Chef::ShellOut.new("pkgutil --pkgs").run_command
+ osx_gcc_installer_installed = result.stdout.split("\n").include?("com.apple.pkg.gcc4.2Leo")
+ developer_tools_cli_installed = result.stdout.split("\n").include?("com.apple.pkg.DeveloperToolsCLI")
+ pkg_filename = File.basename(node['build_essential']['osx']['gcc_installer_url'])
+ pkg_path = "#{Chef::Config[:file_cache_path]}/#{pkg_filename}"
-package "bison" do
- action :install
+ r = remote_file pkg_path do
+ source node['build_essential']['osx']['gcc_installer_url']
+ checksum node['build_essential']['osx']['gcc_installer_checksum']
+ action ( compiletime ? :nothing : :create )
+ not_if { osx_gcc_installer_installed or developer_tools_cli_installed }
+ end
+ r.run_action(:create) if compiletime
+
+ r = execute "sudo installer -pkg \"#{pkg_path}\" -target /" do
+ action ( compiletime ? :nothing : :run )
+ not_if { osx_gcc_installer_installed or developer_tools_cli_installed }
+ end
+ r.run_action(:run) if compiletime
end

0 comments on commit 2e1de35

Please sign in to comment.
Something went wrong with that request. Please try again.