natives 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +15 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +17 -0
  5. data/Gemfile.lock +137 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +19 -0
  8. data/Rakefile +42 -0
  9. data/VERSION +1 -0
  10. data/bin/natives +7 -0
  11. data/chef-solo/.gitignore +17 -0
  12. data/chef-solo/.kitchen.yml +27 -0
  13. data/chef-solo/Berksfile +4 -0
  14. data/chef-solo/config.rb +17 -0
  15. data/chef-solo/vendored-cookbooks/apt/CHANGELOG.md +144 -0
  16. data/chef-solo/vendored-cookbooks/apt/README.md +247 -0
  17. data/chef-solo/vendored-cookbooks/apt/attributes/default.rb +27 -0
  18. data/chef-solo/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  19. data/chef-solo/vendored-cookbooks/apt/libraries/helpers.rb +47 -0
  20. data/chef-solo/vendored-cookbooks/apt/libraries/network.rb +33 -0
  21. data/chef-solo/vendored-cookbooks/apt/metadata.json +54 -0
  22. data/chef-solo/vendored-cookbooks/apt/metadata.rb +34 -0
  23. data/chef-solo/vendored-cookbooks/apt/providers/preference.rb +61 -0
  24. data/chef-solo/vendored-cookbooks/apt/providers/repository.rb +141 -0
  25. data/chef-solo/vendored-cookbooks/apt/recipes/cacher-client.rb +81 -0
  26. data/chef-solo/vendored-cookbooks/apt/recipes/cacher-ng.rb +43 -0
  27. data/chef-solo/vendored-cookbooks/apt/recipes/default.rb +83 -0
  28. data/chef-solo/vendored-cookbooks/apt/resources/preference.rb +30 -0
  29. data/chef-solo/vendored-cookbooks/apt/resources/repository.rb +41 -0
  30. data/chef-solo/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb +173 -0
  31. data/chef-solo/vendored-cookbooks/apt/templates/default/01proxy.erb +5 -0
  32. data/chef-solo/vendored-cookbooks/apt/templates/default/acng.conf.erb +275 -0
  33. data/chef-solo/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +269 -0
  34. data/chef-solo/vendored-cookbooks/homebrew/CHANGELOG.md +36 -0
  35. data/chef-solo/vendored-cookbooks/homebrew/README.md +110 -0
  36. data/chef-solo/vendored-cookbooks/homebrew/attributes/default.rb +22 -0
  37. data/chef-solo/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb +53 -0
  38. data/chef-solo/vendored-cookbooks/homebrew/libraries/homebrew_package.rb +104 -0
  39. data/chef-solo/vendored-cookbooks/homebrew/metadata.json +32 -0
  40. data/chef-solo/vendored-cookbooks/homebrew/metadata.rb +10 -0
  41. data/chef-solo/vendored-cookbooks/homebrew/providers/tap.rb +48 -0
  42. data/chef-solo/vendored-cookbooks/homebrew/recipes/default.rb +46 -0
  43. data/chef-solo/vendored-cookbooks/homebrew/resources/tap.rb +35 -0
  44. data/lib/natives/app.rb +53 -0
  45. data/lib/natives/cli.rb +11 -0
  46. data/lib/natives.rb +0 -0
  47. data/natives.gemspec +113 -0
  48. data/spec/natives/app_spec.rb +68 -0
  49. data/spec/spec_helper.rb +12 -0
  50. metadata +224 -0
@@ -0,0 +1,247 @@
1
+ apt Cookbook
2
+ ============
3
+ 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.
4
+
5
+
6
+ Requirements
7
+ ------------
8
+ **Version 2.0.0+ of this cookbook requires Chef 11.0.0 or later**. If your Chef version is earlier than 11.0.0, use version 1.10.0 of this cookbook.
9
+
10
+ Version 1.8.2 to 1.10.0 of this cookbook requires **Chef 10.16.4** or later.
11
+
12
+ If your Chef version is earlier than 10.16.4, use version 1.7.0 of this cookbook.
13
+
14
+ ### Platform
15
+ Please refer to the [TESTING file](TESTING.md) to see the currently (and passing) tested platforms. The release was tested on:
16
+
17
+ * Ubuntu 10.04
18
+ * Ubuntu 12.04
19
+ * Ubuntu 13.04
20
+ * Debian 7.1
21
+ * Debian 6.0 (have with manual testing)
22
+
23
+ May work with or without modification on other Debian derivatives.
24
+
25
+
26
+ -------
27
+ ### default
28
+ 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.
29
+
30
+ 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.
31
+
32
+ This recipe also sets up a local cache directory for preseeding packages.
33
+
34
+ **Including the default recipe on a node that does not support apt (such as Windows) results in a noop.**
35
+
36
+ ### cacher-client
37
+ Configures the node to use the `apt-cacher-ng` server as a client.
38
+
39
+ #### Bypassing the cache
40
+ Occasionally you may come across repositories that do not play nicely when the node is using an `apt-cacher-ng` server. You can configure `cacher-client` to bypass the server and connect directly to the repository with the `cache_bypass` attribute.
41
+
42
+ To do this, you need to override the `cache_bypass` attribute with an array of repositories, with each array key as the repository URL and value as the protocol to use:
43
+
44
+ ```json
45
+ {
46
+ ...,
47
+ 'apt': {
48
+ ...,
49
+ 'cache_bypass': {
50
+ URL: PROTOCOL
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ For example, to prevent caching and directly connect to the repository at `download.oracle.com` via http:
57
+
58
+ ```json
59
+ {
60
+ 'apt': {
61
+ 'cache_bypass': {
62
+ 'download.oracle.com': 'http'
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ ### cacher-ng
69
+ 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.
70
+
71
+ If you wish to help the `cacher-ng` recipe seed itself, you must now explicitly include the `cacher-client` recipe in your run list **after** `cacher-ng` or you will block your ability to install any packages (ie. `apt-cacher-ng`).
72
+
73
+
74
+ Attributes
75
+ ----------
76
+ * `['apt']['cacher_ipaddress']` - use a cacher server (or standard proxy server) not available via search
77
+ * `['apt']['cacher_interface]` - interface to connect to the cacher-ng service, no default.
78
+ * `['apt']['cacher_port']` - port for the cacher-ng service (either client or server), default is '3142'
79
+ * `['apt']['cacher_dir']` - directory used by cacher-ng service, default is '/var/cache/apt-cacher-ng'
80
+ * `['apt']['cacher-client']['restrict_environment']` - restrict your node to using the `apt-cacher-ng` server in your Environment, default is 'false'
81
+ * `['apt']['compiletime']` - force the `cacher-client` recipe to run before other recipes. It forces apt to use the proxy before other recipes run. Useful if your nodes have limited access to public apt repositories. This is overridden if the `cacher-ng` recipe is in your run list. Default is 'false'
82
+ * `['apt']['cache_bypass']` - array of URLs to bypass the cache. Accepts the URL and protocol to fetch directly from the remote repository and not attempt to cache
83
+
84
+ Libraries
85
+ ---------
86
+ There is an `interface_ipaddress` method that returns the IP address for a particular host and interface, used by the `cacher-client` recipe. To enable it on the server use the `['apt']['cacher_interface']` attribute.
87
+
88
+ Resources/Providers
89
+ -------------------
90
+ ### `apt_repository`
91
+ 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.
92
+
93
+ #### Actions
94
+ - :add: creates a repository file and builds the repository listing
95
+ - :remove: removes the repository file
96
+
97
+ #### Attribute Parameters
98
+ - repo_name: name attribute. The name of the channel to discover
99
+ - uri: the base of the Debian distribution
100
+ - distribution: this is usually your release's codename...ie something like `karmic`, `lucid` or `maverick`
101
+ - components: package groupings..when it doubt use `main`
102
+ - arch: constrain package to a particular arch like `i386`, `amd64` or even `armhf` or `powerpc`. Defaults to nil.
103
+ - trusted: treat all packages from this repository as authenticated regardless of signature
104
+ - deb_src: whether or not to add the repository as a source repo as well - value can be `true` or `false`, default `false`.
105
+ - keyserver: the GPG keyserver where the key for the repo should be retrieved
106
+ - 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.
107
+ - key_proxy: if set, pass the specified proxy via `http-proxy=` to GPG.
108
+ - 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.
109
+
110
+ #### Examples
111
+
112
+ Add the Zenoss repo:
113
+
114
+ ```ruby
115
+ apt_repository 'zenoss' do
116
+ uri 'http://dev.zenoss.org/deb'
117
+ components ['main', 'stable']
118
+ end
119
+ ```
120
+
121
+ Add the Nginx PPA, grabbing the key from keyserver:
122
+
123
+ ```ruby
124
+ apt_repository 'nginx-php' do
125
+ uri 'http://ppa.launchpad.net/nginx/php5/ubuntu'
126
+ distribution node['lsb']['codename']
127
+ components ['main']
128
+ keyserver 'keyserver.ubuntu.com'
129
+ key 'C300EE8C'
130
+ end
131
+ ```
132
+
133
+ Add the Nginx PPA, grab the key from the keyserver, and add source repo:
134
+
135
+ ```ruby
136
+ apt_repository 'nginx-php' do
137
+ uri 'http://ppa.launchpad.net/nginx/php5/ubuntu'
138
+ distribution node['lsb']['codename']
139
+ components ['main']
140
+ keyserver 'keyserver.ubuntu.com'
141
+ key 'C300EE8C'
142
+ deb_src true
143
+ end
144
+ ```
145
+
146
+ Add the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64:
147
+
148
+ ```ruby
149
+ apt_repository 'cloudera' do
150
+ uri 'http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh'
151
+ arch 'amd64'
152
+ distribution 'precise-cdh4'
153
+ components ['contrib']
154
+ key 'http://archive.cloudera.com/debian/archive.key'
155
+ end
156
+ ```
157
+
158
+ Remove Zenoss repo:
159
+
160
+ ```ruby
161
+ apt_repository 'zenoss' do
162
+ action :remove
163
+ end
164
+ ```
165
+
166
+ ### `apt_preference`
167
+ 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.
168
+
169
+ Further information regarding apt-pinning is available via http://wiki.debian.org/AptPreferences.
170
+
171
+ #### Actions
172
+ - :add: creates a preferences file under /etc/apt/preferences.d
173
+ - :remove: Removes the file, therefore unpin the package
174
+
175
+ #### Attribute Parameters
176
+ - package_name: name attribute. The name of the package
177
+ - glob: Pin by glob() expression or regexp surrounded by /.
178
+ - pin: The package version/repository to pin
179
+ - pin_priority: The pinning priority aka "the highest package version wins"
180
+
181
+ #### Examples
182
+ Pin libmysqlclient16 to version 5.1.49-3:
183
+
184
+ ```ruby
185
+ apt_preference 'libmysqlclient16' do
186
+ pin 'version 5.1.49-3'
187
+ pin_priority '700'
188
+ end
189
+ ```
190
+
191
+ Unpin libmysqlclient16:
192
+
193
+ ```ruby
194
+ apt_preference 'libmysqlclient16' do
195
+ action :remove
196
+ end
197
+ ```
198
+
199
+ Pin all packages from dotdeb.org:
200
+
201
+ ```ruby
202
+ apt_preference 'dotdeb' do
203
+ glob '*'
204
+ pin 'origin packages.dotdeb.org'
205
+ pin_priority '700'
206
+ end
207
+ ```
208
+
209
+
210
+ Usage
211
+ -----
212
+ 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.:
213
+
214
+ ```ruby
215
+ template '/etc/apt/sources.list.d/my_apt_sources.list' do
216
+ notifies :run, 'execute[apt-get update]', :immediately
217
+ end
218
+ ```
219
+
220
+ 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.
221
+
222
+ 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.
223
+
224
+ If you want to cleanup unused packages, there is also the `apt-get autoclean` and `apt-get autoremove` resources provided for automated cleanup.
225
+
226
+
227
+ License & Authors
228
+ -----------------
229
+ - Author:: Joshua Timberman (joshua@opscode.com)
230
+ - Author:: Matt Ray (matt@opscode.com)
231
+ - Author:: Seth Chisamore (schisamo@opscode.com)
232
+
233
+ ```text
234
+ Copyright 2009-2013, Opscode, Inc.
235
+
236
+ Licensed under the Apache License, Version 2.0 (the "License");
237
+ you may not use this file except in compliance with the License.
238
+ You may obtain a copy of the License at
239
+
240
+ http://www.apache.org/licenses/LICENSE-2.0
241
+
242
+ Unless required by applicable law or agreed to in writing, software
243
+ distributed under the License is distributed on an "AS IS" BASIS,
244
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
245
+ See the License for the specific language governing permissions and
246
+ limitations under the License.
247
+ ```
@@ -0,0 +1,27 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Attributes:: default
4
+ #
5
+ # Copyright 2009-2013, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ default['apt']['cacher-client']['restrict_environment'] = false
21
+ default['apt']['cacher_dir'] = '/var/cache/apt-cacher-ng'
22
+ default['apt']['cacher_interface'] = nil
23
+ default['apt']['cacher_port'] = 3142
24
+ default['apt']['caching_server'] = false
25
+ default['apt']['compiletime'] = false
26
+ default['apt']['key_proxy'] = ''
27
+ default['apt']['cache_bypass'] = {}
@@ -0,0 +1,50 @@
1
+ [DEFAULT]
2
+ ;; All times are in seconds, but you can add a suffix
3
+ ;; for minutes(m), hours(h) or days(d)
4
+
5
+ ;; commented out address so apt-proxy will listen on all IPs
6
+ ;; address = 127.0.0.1
7
+ port = 9999
8
+ cache_dir = /var/cache/apt-proxy
9
+
10
+ ;; Control files (Packages/Sources/Contents) refresh rate
11
+ min_refresh_delay = 1s
12
+ complete_clientless_downloads = 1
13
+
14
+ ;; Debugging settings.
15
+ debug = all:4 db:0
16
+
17
+ time = 30
18
+ passive_ftp = on
19
+
20
+ ;;--------------------------------------------------------------
21
+ ;; Cache housekeeping
22
+
23
+ cleanup_freq = 1d
24
+ max_age = 120d
25
+ max_versions = 3
26
+
27
+ ;;---------------------------------------------------------------
28
+ ;; Backend servers
29
+ ;;
30
+ ;; Place each server in its own [section]
31
+
32
+ [ubuntu]
33
+ ; Ubuntu archive
34
+ backends =
35
+ http://us.archive.ubuntu.com/ubuntu
36
+
37
+ [ubuntu-security]
38
+ ; Ubuntu security updates
39
+ backends = http://security.ubuntu.com/ubuntu
40
+
41
+ [debian]
42
+ ;; Backend servers, in order of preference
43
+ backends =
44
+ http://debian.osuosl.org/debian/
45
+
46
+ [security]
47
+ ;; Debian security archive
48
+ backends =
49
+ http://security.debian.org/debian-security
50
+ http://ftp2.de.debian.org/debian-security
@@ -0,0 +1,47 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Library:: helpers
4
+ #
5
+ # Copyright 2013 Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ module Apt
21
+ module Helpers
22
+ # Determines if apt is installed on a system.
23
+ #
24
+ # @return [Boolean]
25
+ def apt_installed?
26
+ !which('apt-get').nil?
27
+ end
28
+
29
+ # Finds a command in $PATH
30
+ #
31
+ # @return [String, nil]
32
+ def which(cmd)
33
+ paths = (ENV['PATH'].split(::File::PATH_SEPARATOR) + %w(/bin /usr/bin /sbin /usr/sbin))
34
+
35
+ paths.each do |path|
36
+ possible = File.join(path, cmd)
37
+ return possible if File.executable?(possible)
38
+ end
39
+
40
+ nil
41
+ end
42
+ end
43
+ end
44
+
45
+ Chef::Recipe.send(:include, ::Apt::Helpers)
46
+ Chef::Resource.send(:include, ::Apt::Helpers)
47
+ Chef::Provider.send(:include, ::Apt::Helpers)
@@ -0,0 +1,33 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # library:: network
4
+ #
5
+ # Copyright 2013, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ module ::Apt
21
+ def interface_ipaddress(host, interface)
22
+ if interface
23
+ addresses = host['network']['interfaces'][interface]['addresses']
24
+ addresses.select do |ip, data|
25
+ if data['family'].eql?('inet')
26
+ return ip
27
+ end
28
+ end
29
+ else
30
+ return host.ipaddress
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "apt",
3
+ "version": "2.3.0",
4
+ "description": "Configures apt and apt services and LWRPs for managing apt repositories and preferences",
5
+ "long_description": "apt Cookbook\n============\nThis 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.\n\n\nRequirements\n------------\n**Version 2.0.0+ of this cookbook requires Chef 11.0.0 or later**. If your Chef version is earlier than 11.0.0, use version 1.10.0 of this cookbook.\n\nVersion 1.8.2 to 1.10.0 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 this cookbook.\n\n### Platform\nPlease refer to the [TESTING file](TESTING.md) to see the currently (and passing) tested platforms. The release was tested on:\n\n* Ubuntu 10.04\n* Ubuntu 12.04\n* Ubuntu 13.04\n* Debian 7.1\n* Debian 6.0 (have with manual testing)\n\nMay work with or without modification on other Debian derivatives.\n\n\n-------\n### default\nThis 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.\n\nThis recipe should appear first in the run list of Debian or Ubuntu nodes to ensure that the package cache is up to date before managing any `package` resources with Chef.\n\nThis recipe also sets up a local cache directory for preseeding packages.\n\n**Including the default recipe on a node that does not support apt (such as Windows) results in a noop.**\n\n### cacher-client\nConfigures the node to use the `apt-cacher-ng` server as a client.\n\n#### Bypassing the cache\nOccasionally you may come across repositories that do not play nicely when the node is using an `apt-cacher-ng` server. You can configure `cacher-client` to bypass the server and connect directly to the repository with the `cache_bypass` attribute.\n\nTo do this, you need to override the `cache_bypass` attribute with an array of repositories, with each array key as the repository URL and value as the protocol to use:\n\n```json\n{\n ...,\n 'apt': {\n ...,\n 'cache_bypass': {\n URL: PROTOCOL\n }\n }\n}\n```\n\nFor example, to prevent caching and directly connect to the repository at `download.oracle.com` via http:\n\n```json\n{\n 'apt': {\n 'cache_bypass': {\n 'download.oracle.com': 'http'\n }\n }\n}\n```\n\n### cacher-ng\nInstalls 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.\n\nIf you wish to help the `cacher-ng` recipe seed itself, you must now explicitly include the `cacher-client` recipe in your run list **after** `cacher-ng` or you will block your ability to install any packages (ie. `apt-cacher-ng`).\n\n\nAttributes\n----------\n* `['apt']['cacher_ipaddress']` - use a cacher server (or standard proxy server) not available via search\n* `['apt']['cacher_interface]` - interface to connect to the cacher-ng service, no default.\n* `['apt']['cacher_port']` - port for the cacher-ng service (either client or server), default is '3142'\n* `['apt']['cacher_dir']` - directory used by cacher-ng service, default is '/var/cache/apt-cacher-ng'\n* `['apt']['cacher-client']['restrict_environment']` - restrict your node to using the `apt-cacher-ng` server in your Environment, default is 'false'\n* `['apt']['compiletime']` - force the `cacher-client` recipe to run before other recipes. It forces apt to use the proxy before other recipes run. Useful if your nodes have limited access to public apt repositories. This is overridden if the `cacher-ng` recipe is in your run list. Default is 'false'\n* `['apt']['cache_bypass']` - array of URLs to bypass the cache. Accepts the URL and protocol to fetch directly from the remote repository and not attempt to cache\n\nLibraries\n---------\nThere is an `interface_ipaddress` method that returns the IP address for a particular host and interface, used by the `cacher-client` recipe. To enable it on the server use the `['apt']['cacher_interface']` attribute.\n\nResources/Providers\n-------------------\n### `apt_repository`\nThis LWRP provides an easy way to manage additional APT repositories. Adding a new repository will notify running the `execute[apt-get-update]` resource immediately.\n\n#### Actions\n- :add: creates a repository file and builds the repository listing\n- :remove: removes the repository file\n\n#### Attribute Parameters\n- repo_name: name attribute. The name of the channel to discover\n- uri: the base of the Debian distribution\n- distribution: this is usually your release's codename...ie something like `karmic`, `lucid` or `maverick`\n- components: package groupings..when it doubt use `main`\n- arch: constrain package to a particular arch like `i386`, `amd64` or even `armhf` or `powerpc`. Defaults to nil.\n- trusted: treat all packages from this repository as authenticated regardless of signature\n- deb_src: whether or not to add the repository as a source repo as 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 fingerprint, otherwise it can be either the URI to the GPG key for 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 the key is located for files/default. Defaults to nil, so it will use the cookbook where the resource is used.\n\n#### Examples\n\nAdd the Zenoss repo:\n\n```ruby\napt_repository 'zenoss' do\n uri 'http://dev.zenoss.org/deb'\n components ['main', 'stable']\nend\n```\n\nAdd the Nginx PPA, grabbing the key from keyserver:\n\n```ruby\napt_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'\nend\n```\n\nAdd the Nginx PPA, grab the key from the keyserver, and add source repo:\n\n```ruby\napt_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\nend\n```\n\nAdd the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64:\n\n```ruby\napt_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'\nend\n```\n\nRemove Zenoss repo:\n\n```ruby\napt_repository 'zenoss' do\n action :remove\nend\n```\n\n### `apt_preference`\nThis 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.\n\nFurther information regarding apt-pinning is available via http://wiki.debian.org/AptPreferences.\n\n#### Actions\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- 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\nPin libmysqlclient16 to version 5.1.49-3:\n\n```ruby\napt_preference 'libmysqlclient16' do\n pin 'version 5.1.49-3'\n pin_priority '700'\nend\n```\n\nUnpin libmysqlclient16:\n\n```ruby\napt_preference 'libmysqlclient16' do\n action :remove\nend\n```\n\nPin all packages from dotdeb.org:\n\n```ruby\napt_preference 'dotdeb' do\n glob '*'\n pin 'origin packages.dotdeb.org'\n pin_priority '700'\nend\n```\n\n\nUsage\n-----\nPut `recipe[apt]` first in the run list. If you have other recipes that you want to use to configure how apt behaves, like new sources, notify the execute resource to run, e.g.:\n\n```ruby\ntemplate '/etc/apt/sources.list.d/my_apt_sources.list' do\n notifies :run, 'execute[apt-get update]', :immediately\nend\n```\n\nThe above will run during execution phase since it is a normal template resource, and should appear before other package resources that need the sources in the template.\n\nPut `recipe[apt::cacher-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.\n\nIf you want to cleanup unused packages, there is also the `apt-get autoclean` and `apt-get autoremove` resources provided for automated cleanup.\n\n\nLicense & Authors\n-----------------\n- Author:: Joshua Timberman (joshua@opscode.com)\n- Author:: Matt Ray (matt@opscode.com)\n- Author:: Seth Chisamore (schisamo@opscode.com)\n\n```text\nCopyright 2009-2013, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
6
+ "maintainer": "Opscode, Inc.",
7
+ "maintainer_email": "cookbooks@opscode.com",
8
+ "license": "Apache 2.0",
9
+ "platforms": {
10
+ "ubuntu": ">= 0.0.0",
11
+ "debian": ">= 0.0.0"
12
+ },
13
+ "dependencies": {
14
+ },
15
+ "recommendations": {
16
+ },
17
+ "suggestions": {
18
+ },
19
+ "conflicting": {
20
+ },
21
+ "providing": {
22
+ },
23
+ "replacing": {
24
+ },
25
+ "attributes": {
26
+ "apt/cacher-client/restrict_environment": {
27
+ "description": "Whether to restrict the search for the caching server to the same environment as this node",
28
+ "default": "false"
29
+ },
30
+ "apt/cacher_port": {
31
+ "description": "Default listen port for the caching server",
32
+ "default": "3142"
33
+ },
34
+ "apt/cacher_interface": {
35
+ "description": "Default listen interface for the caching server",
36
+ "default": null
37
+ },
38
+ "apt/key_proxy": {
39
+ "description": "Passed as the proxy passed to GPG for the apt_repository resource",
40
+ "default": ""
41
+ },
42
+ "apt/caching_server": {
43
+ "description": "Set this to true if the node is a caching server",
44
+ "default": "false"
45
+ }
46
+ },
47
+ "groupings": {
48
+ },
49
+ "recipes": {
50
+ "apt": "Runs apt-get update during compile phase and sets up preseed directories",
51
+ "apt::cacher-ng": "Set up an apt-cacher-ng caching proxy",
52
+ "apt::cacher-client": "Client for the apt::cacher-ng caching proxy"
53
+ }
54
+ }
@@ -0,0 +1,34 @@
1
+ name "apt"
2
+ maintainer "Opscode, Inc."
3
+ maintainer_email "cookbooks@opscode.com"
4
+ license "Apache 2.0"
5
+ description "Configures apt and apt services and LWRPs for managing apt repositories and preferences"
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version "2.3.0"
8
+ recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories"
9
+ recipe "apt::cacher-ng", "Set up an apt-cacher-ng caching proxy"
10
+ recipe "apt::cacher-client", "Client for the apt::cacher-ng caching proxy"
11
+
12
+ %w{ ubuntu debian }.each do |os|
13
+ supports os
14
+ end
15
+
16
+ attribute "apt/cacher-client/restrict_environment",
17
+ :description => "Whether to restrict the search for the caching server to the same environment as this node",
18
+ :default => "false"
19
+
20
+ attribute "apt/cacher_port",
21
+ :description => "Default listen port for the caching server",
22
+ :default => "3142"
23
+
24
+ attribute "apt/cacher_interface",
25
+ :description => "Default listen interface for the caching server",
26
+ :default => nil
27
+
28
+ attribute "apt/key_proxy",
29
+ :description => "Passed as the proxy passed to GPG for the apt_repository resource",
30
+ :default => ""
31
+
32
+ attribute "apt/caching_server",
33
+ :description => "Set this to true if the node is a caching server",
34
+ :default => "false"
@@ -0,0 +1,61 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Provider:: preference
4
+ #
5
+ # Copyright 2010-2011, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ # Build preferences.d file contents
21
+ def build_pref(package_name, pin, pin_priority)
22
+ preference_content = "Package: #{package_name}\nPin: #{pin}\nPin-Priority: #{pin_priority}\n"
23
+ end
24
+
25
+ action :add do
26
+ new_resource.updated_by_last_action(false)
27
+
28
+ preference = build_pref(new_resource.glob || new_resource.package_name,
29
+ new_resource.pin,
30
+ new_resource.pin_priority)
31
+
32
+ preference_dir = directory "/etc/apt/preferences.d" do
33
+ owner "root"
34
+ group "root"
35
+ mode 00755
36
+ recursive true
37
+ action :nothing
38
+ end
39
+
40
+ preference_file = file "/etc/apt/preferences.d/#{new_resource.name}" do
41
+ owner "root"
42
+ group "root"
43
+ mode 00644
44
+ content preference
45
+ action :nothing
46
+ end
47
+
48
+ preference_dir.run_action(:create)
49
+ # write out the preference file, replace it if it already exists
50
+ preference_file.run_action(:create)
51
+ end
52
+
53
+ action :remove do
54
+ if ::File.exists?("/etc/apt/preferences.d/#{new_resource.name}")
55
+ Chef::Log.info "Un-pinning #{new_resource.name} from /etc/apt/preferences.d/"
56
+ file "/etc/apt/preferences.d/#{new_resource.name}" do
57
+ action :delete
58
+ end
59
+ new_resource.updated_by_last_action(true)
60
+ end
61
+ end