natives 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +2 -3
- data/Gemfile.lock +12 -53
- data/README.md +126 -29
- data/Rakefile +4 -5
- data/VERSION +1 -1
- data/bin/natives +1 -0
- data/catalogs/rubygems.yaml +50 -0
- data/lib/natives/apps/detect.rb +21 -0
- data/lib/natives/apps/list.rb +39 -0
- data/lib/natives/apps.rb +2 -0
- data/lib/natives/catalog/loader.rb +30 -0
- data/lib/natives/catalog/merger.rb +26 -0
- data/lib/natives/catalog/selector.rb +79 -0
- data/lib/natives/catalog/validator.rb +18 -0
- data/lib/natives/catalog.rb +56 -0
- data/lib/natives/cli.rb +27 -42
- data/lib/natives/gemfile_viewer.rb +19 -16
- data/lib/natives/host_detection/package_provider.rb +83 -0
- data/lib/natives/host_detection/platform.rb +34 -0
- data/lib/natives/host_detection.rb +25 -0
- data/lib/natives.rb +1 -0
- data/spec/fixtures/dir_with_matching_files/invalid1.yml +9 -0
- data/spec/fixtures/dir_with_matching_files/not_matching.json +0 -0
- data/spec/fixtures/dir_with_matching_files/valid1.yaml +21 -0
- data/spec/fixtures/dir_with_matching_files/valid2.yml +9 -0
- data/spec/fixtures/dir_without_matching_file/not_matching.json +0 -0
- data/spec/natives/apps/detect_spec.rb +26 -0
- data/spec/natives/apps/list_spec.rb +58 -0
- data/spec/natives/catalog/loader_spec.rb +101 -0
- data/spec/natives/catalog/merger_spec.rb +60 -0
- data/spec/natives/catalog/selector_spec.rb +124 -0
- data/spec/natives/catalog/validator_spec.rb +44 -0
- data/spec/natives/catalog_spec.rb +133 -0
- data/spec/natives/gemfile_viewer_spec.rb +3 -3
- data/spec/natives/host_detection/package_provider_spec.rb +33 -0
- data/spec/natives/host_detection/platform_spec.rb +21 -0
- data/spec/natives/host_detection_spec.rb +45 -0
- data/spec/spec_helper.rb +17 -2
- metadata +44 -66
- data/chef/.kitchen.yml +0 -27
- data/chef/Berksfile +0 -4
- data/chef/Berksfile.lock +0 -10
- data/chef/cookbooks/natives/Berksfile +0 -3
- data/chef/cookbooks/natives/Gemfile +0 -5
- data/chef/cookbooks/natives/LICENSE +0 -3
- data/chef/cookbooks/natives/README.md +0 -13
- data/chef/cookbooks/natives/chefignore +0 -96
- data/chef/cookbooks/natives/libraries/natives_recipe_helper.rb +0 -37
- data/chef/cookbooks/natives/metadata.rb +0 -9
- data/chef/cookbooks/natives/recipes/default.rb +0 -31
- data/chef/solo.rb +0 -17
- data/chef/vendored-cookbooks/apt/CHANGELOG.md +0 -144
- data/chef/vendored-cookbooks/apt/README.md +0 -247
- data/chef/vendored-cookbooks/apt/attributes/default.rb +0 -27
- data/chef/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf +0 -50
- data/chef/vendored-cookbooks/apt/libraries/helpers.rb +0 -47
- data/chef/vendored-cookbooks/apt/libraries/network.rb +0 -33
- data/chef/vendored-cookbooks/apt/metadata.json +0 -54
- data/chef/vendored-cookbooks/apt/metadata.rb +0 -34
- data/chef/vendored-cookbooks/apt/providers/preference.rb +0 -61
- data/chef/vendored-cookbooks/apt/providers/repository.rb +0 -141
- data/chef/vendored-cookbooks/apt/recipes/cacher-client.rb +0 -81
- data/chef/vendored-cookbooks/apt/recipes/cacher-ng.rb +0 -43
- data/chef/vendored-cookbooks/apt/recipes/default.rb +0 -83
- data/chef/vendored-cookbooks/apt/resources/preference.rb +0 -30
- data/chef/vendored-cookbooks/apt/resources/repository.rb +0 -41
- data/chef/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb +0 -173
- data/chef/vendored-cookbooks/apt/templates/default/01proxy.erb +0 -5
- data/chef/vendored-cookbooks/apt/templates/default/acng.conf.erb +0 -275
- data/chef/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +0 -269
- data/chef/vendored-cookbooks/homebrew/CHANGELOG.md +0 -36
- data/chef/vendored-cookbooks/homebrew/README.md +0 -110
- data/chef/vendored-cookbooks/homebrew/attributes/default.rb +0 -22
- data/chef/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb +0 -53
- data/chef/vendored-cookbooks/homebrew/libraries/homebrew_package.rb +0 -104
- data/chef/vendored-cookbooks/homebrew/metadata.json +0 -32
- data/chef/vendored-cookbooks/homebrew/metadata.rb +0 -10
- data/chef/vendored-cookbooks/homebrew/providers/tap.rb +0 -48
- data/chef/vendored-cookbooks/homebrew/recipes/default.rb +0 -46
- data/chef/vendored-cookbooks/homebrew/resources/tap.rb +0 -35
- data/lib/natives/app.rb +0 -71
- data/natives.gemspec +0 -125
- data/spec/natives/app_spec.rb +0 -153
@@ -1,50 +0,0 @@
|
|
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
|
@@ -1,47 +0,0 @@
|
|
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)
|
@@ -1,33 +0,0 @@
|
|
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
|
@@ -1,54 +0,0 @@
|
|
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
|
-
}
|
@@ -1,34 +0,0 @@
|
|
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"
|
@@ -1,61 +0,0 @@
|
|
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
|
@@ -1,141 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Cookbook Name:: apt
|
3
|
-
# Provider:: repository
|
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
|
-
use_inline_resources if defined?(use_inline_resources)
|
21
|
-
|
22
|
-
def whyrun_supported?
|
23
|
-
true
|
24
|
-
end
|
25
|
-
|
26
|
-
# install apt key from keyserver
|
27
|
-
def install_key_from_keyserver(key, keyserver)
|
28
|
-
execute "install-key #{key}" do
|
29
|
-
if !node['apt']['key_proxy'].empty?
|
30
|
-
command "apt-key adv --keyserver-options http-proxy=#{node['apt']['key_proxy']} --keyserver hkp://#{keyserver}:80 --recv #{key}"
|
31
|
-
else
|
32
|
-
command "apt-key adv --keyserver #{keyserver} --recv #{key}"
|
33
|
-
end
|
34
|
-
action :run
|
35
|
-
not_if do
|
36
|
-
extract_fingerprints_from_cmd("apt-key finger").any? do |fingerprint|
|
37
|
-
fingerprint.end_with?(key.upcase)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# run command and extract gpg ids
|
44
|
-
def extract_fingerprints_from_cmd(cmd)
|
45
|
-
so = Mixlib::ShellOut.new(cmd)
|
46
|
-
so.run_command
|
47
|
-
so.stdout.split(/\n/).collect do |t|
|
48
|
-
if z = t.match(/^ +Key fingerprint = ([0-9A-F ]+)/)
|
49
|
-
z[1].split.join
|
50
|
-
end
|
51
|
-
end.compact
|
52
|
-
end
|
53
|
-
|
54
|
-
# install apt key from URI
|
55
|
-
def install_key_from_uri(uri)
|
56
|
-
key_name = uri.split(/\//).last
|
57
|
-
cached_keyfile = "#{Chef::Config[:file_cache_path]}/#{key_name}"
|
58
|
-
if new_resource.key =~ /http/
|
59
|
-
remote_file cached_keyfile do
|
60
|
-
source new_resource.key
|
61
|
-
mode 00644
|
62
|
-
action :create
|
63
|
-
end
|
64
|
-
else
|
65
|
-
cookbook_file cached_keyfile do
|
66
|
-
source new_resource.key
|
67
|
-
cookbook new_resource.cookbook
|
68
|
-
mode 00644
|
69
|
-
action :create
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
execute "install-key #{key_name}" do
|
74
|
-
command "apt-key add #{cached_keyfile}"
|
75
|
-
action :run
|
76
|
-
not_if do
|
77
|
-
installed_keys = extract_fingerprints_from_cmd("apt-key finger")
|
78
|
-
proposed_keys = extract_fingerprints_from_cmd("gpg --with-fingerprint #{cached_keyfile}")
|
79
|
-
(installed_keys & proposed_keys).sort == proposed_keys.sort
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# build repo file contents
|
85
|
-
def build_repo(uri, distribution, components, trusted, arch, add_deb_src)
|
86
|
-
components = components.join(' ') if components.respond_to?(:join)
|
87
|
-
repo_options = []
|
88
|
-
repo_options << "arch=#{arch}" if arch
|
89
|
-
repo_options << "trusted=yes" if trusted
|
90
|
-
repo_options = "[" + repo_options.join(' ') + "]" unless repo_options.empty?
|
91
|
-
repo_info = "#{uri} #{distribution} #{components}\n"
|
92
|
-
repo_info = "#{repo_options} #{repo_info}" unless repo_options.empty?
|
93
|
-
repo = "deb #{repo_info}"
|
94
|
-
repo << "deb-src #{repo_info}" if add_deb_src
|
95
|
-
repo
|
96
|
-
end
|
97
|
-
|
98
|
-
action :add do
|
99
|
-
# add key
|
100
|
-
if new_resource.keyserver && new_resource.key
|
101
|
-
install_key_from_keyserver(new_resource.key, new_resource.keyserver)
|
102
|
-
elsif new_resource.key
|
103
|
-
install_key_from_uri(new_resource.key)
|
104
|
-
end
|
105
|
-
|
106
|
-
file "/var/lib/apt/periodic/update-success-stamp" do
|
107
|
-
action :nothing
|
108
|
-
end
|
109
|
-
|
110
|
-
execute "apt-get update" do
|
111
|
-
ignore_failure true
|
112
|
-
action :nothing
|
113
|
-
end
|
114
|
-
|
115
|
-
# build repo file
|
116
|
-
repository = build_repo(new_resource.uri,
|
117
|
-
new_resource.distribution,
|
118
|
-
new_resource.components,
|
119
|
-
new_resource.trusted,
|
120
|
-
new_resource.arch,
|
121
|
-
new_resource.deb_src)
|
122
|
-
|
123
|
-
file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
|
124
|
-
owner "root"
|
125
|
-
group "root"
|
126
|
-
mode 00644
|
127
|
-
content repository
|
128
|
-
action :create
|
129
|
-
notifies :delete, "file[/var/lib/apt/periodic/update-success-stamp]", :immediately
|
130
|
-
notifies :run, "execute[apt-get update]", :immediately if new_resource.cache_rebuild
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
action :remove do
|
135
|
-
if ::File.exists?("/etc/apt/sources.list.d/#{new_resource.name}.list")
|
136
|
-
Chef::Log.info "Removing #{new_resource.name} repository from /etc/apt/sources.list.d/"
|
137
|
-
file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
|
138
|
-
action :delete
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Cookbook Name:: apt
|
3
|
-
# Recipe:: cacher-client
|
4
|
-
#
|
5
|
-
# Copyright 2011-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
|
-
class ::Chef::Recipe
|
21
|
-
include ::Apt
|
22
|
-
end
|
23
|
-
|
24
|
-
#remove Acquire::http::Proxy lines from /etc/apt/apt.conf since we use 01proxy
|
25
|
-
#these are leftover from preseed installs
|
26
|
-
execute 'Remove proxy from /etc/apt/apt.conf' do
|
27
|
-
command "sed --in-place '/^Acquire::http::Proxy/d' /etc/apt/apt.conf"
|
28
|
-
only_if "grep Acquire::http::Proxy /etc/apt/apt.conf"
|
29
|
-
end
|
30
|
-
|
31
|
-
servers = []
|
32
|
-
if node['apt']
|
33
|
-
if node['apt']['cacher_ipaddress']
|
34
|
-
cacher = Chef::Node.new
|
35
|
-
cacher.default.name = node['apt']['cacher_ipaddress']
|
36
|
-
cacher.default.ipaddress = node['apt']['cacher_ipaddress']
|
37
|
-
cacher.default.apt.cacher_port = node['apt']['cacher_port']
|
38
|
-
cacher.default.apt_cacher_interface = node['apt']['cacher_interface']
|
39
|
-
servers << cacher
|
40
|
-
elsif node['apt']['caching_server']
|
41
|
-
node.override['apt']['compiletime'] = false
|
42
|
-
servers << node
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
unless (Chef::Config[:solo] || servers.length > 0)
|
47
|
-
query = "apt_caching_server:true"
|
48
|
-
query += " AND chef_environment:#{node.chef_environment}" if node['apt']['cacher-client']['restrict_environment']
|
49
|
-
Chef::Log.debug("apt::cacher-client searching for '#{query}'")
|
50
|
-
servers += search(:node, query)
|
51
|
-
end
|
52
|
-
|
53
|
-
if servers.length > 0
|
54
|
-
Chef::Log.info("apt-cacher-ng server found on #{servers[0]}.")
|
55
|
-
if servers[0]['apt']['cacher_interface']
|
56
|
-
cacher_ipaddress = interface_ipaddress(servers[0], servers[0]['apt']['cacher_interface'])
|
57
|
-
else
|
58
|
-
cacher_ipaddress = servers[0].ipaddress
|
59
|
-
end
|
60
|
-
t = template '/etc/apt/apt.conf.d/01proxy' do
|
61
|
-
source '01proxy.erb'
|
62
|
-
owner 'root'
|
63
|
-
group 'root'
|
64
|
-
mode 00644
|
65
|
-
variables(
|
66
|
-
:proxy => cacher_ipaddress,
|
67
|
-
:port => servers[0]['apt']['cacher_port'],
|
68
|
-
:bypass => node['apt']['cache_bypass']
|
69
|
-
)
|
70
|
-
action( node['apt']['compiletime'] ? :nothing : :create )
|
71
|
-
notifies :run, 'execute[apt-get update]', :immediately
|
72
|
-
end
|
73
|
-
t.run_action(:create) if node['apt']['compiletime']
|
74
|
-
else
|
75
|
-
Chef::Log.info('No apt-cacher-ng server found.')
|
76
|
-
file '/etc/apt/apt.conf.d/01proxy' do
|
77
|
-
action :delete
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
include_recipe 'apt::default'
|
@@ -1,43 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Cookbook Name:: apt
|
3
|
-
# Recipe:: cacher-ng
|
4
|
-
#
|
5
|
-
# Copyright 2008-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
|
-
node.set['apt']['caching_server'] = true
|
21
|
-
|
22
|
-
package "apt-cacher-ng" do
|
23
|
-
action :install
|
24
|
-
end
|
25
|
-
|
26
|
-
directory node['apt']['cacher_dir'] do
|
27
|
-
owner "apt-cacher-ng"
|
28
|
-
group "apt-cacher-ng"
|
29
|
-
mode 0755
|
30
|
-
end
|
31
|
-
|
32
|
-
template "/etc/apt-cacher-ng/acng.conf" do
|
33
|
-
source "acng.conf.erb"
|
34
|
-
owner "root"
|
35
|
-
group "root"
|
36
|
-
mode 00644
|
37
|
-
notifies :restart, "service[apt-cacher-ng]", :immediately
|
38
|
-
end
|
39
|
-
|
40
|
-
service "apt-cacher-ng" do
|
41
|
-
supports :restart => true, :status => false
|
42
|
-
action [:enable, :start]
|
43
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Cookbook Name:: apt
|
3
|
-
# Recipe:: default
|
4
|
-
#
|
5
|
-
# Copyright 2008-2013, Opscode, Inc.
|
6
|
-
# Copyright 2009, Bryan McLellan <btm@loftninjas.org>
|
7
|
-
#
|
8
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
-
# See the License for the specific language governing permissions and
|
18
|
-
# limitations under the License.
|
19
|
-
#
|
20
|
-
|
21
|
-
# On systems where apt is not installed, the resources in this recipe are not
|
22
|
-
# executed. However, they _must_ still be present in the resource collection
|
23
|
-
# or other cookbooks which notify these resources will fail on non-apt-enabled
|
24
|
-
# systems.
|
25
|
-
unless apt_installed?
|
26
|
-
Chef::Log.debug "apt is not installed. Apt-specific resources will not be executed."
|
27
|
-
end
|
28
|
-
|
29
|
-
# Run apt-get update to create the stamp file
|
30
|
-
execute "apt-get-update" do
|
31
|
-
command "apt-get update"
|
32
|
-
ignore_failure true
|
33
|
-
only_if { apt_installed? }
|
34
|
-
not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end
|
35
|
-
end
|
36
|
-
|
37
|
-
# For other recipes to call to force an update
|
38
|
-
execute "apt-get update" do
|
39
|
-
command "apt-get update"
|
40
|
-
ignore_failure true
|
41
|
-
only_if { apt_installed? }
|
42
|
-
action :nothing
|
43
|
-
end
|
44
|
-
|
45
|
-
# Automatically remove packages that are no longer needed for dependencies
|
46
|
-
execute "apt-get autoremove" do
|
47
|
-
command "apt-get -y autoremove"
|
48
|
-
only_if { apt_installed? }
|
49
|
-
action :nothing
|
50
|
-
end
|
51
|
-
|
52
|
-
# Automatically remove .deb files for packages no longer on your system
|
53
|
-
execute "apt-get autoclean" do
|
54
|
-
command "apt-get -y autoclean"
|
55
|
-
only_if { apt_installed? }
|
56
|
-
action :nothing
|
57
|
-
end
|
58
|
-
|
59
|
-
# provides /var/lib/apt/periodic/update-success-stamp on apt-get update
|
60
|
-
package "update-notifier-common" do
|
61
|
-
notifies :run, 'execute[apt-get-update]', :immediately
|
62
|
-
only_if { apt_installed? }
|
63
|
-
end
|
64
|
-
|
65
|
-
execute "apt-get-update-periodic" do
|
66
|
-
command "apt-get update"
|
67
|
-
ignore_failure true
|
68
|
-
only_if do
|
69
|
-
apt_installed? &&
|
70
|
-
::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
|
71
|
-
::File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
%w{/var/cache/local /var/cache/local/preseeding}.each do |dirname|
|
76
|
-
directory dirname do
|
77
|
-
owner "root"
|
78
|
-
group "root"
|
79
|
-
mode 00755
|
80
|
-
action :create
|
81
|
-
only_if { apt_installed? }
|
82
|
-
end
|
83
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Cookbook Name:: apt
|
3
|
-
# Resource:: preference
|
4
|
-
#
|
5
|
-
# Copyright 2010-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
|
-
actions :add, :remove
|
21
|
-
|
22
|
-
def initialize(*args)
|
23
|
-
super
|
24
|
-
@action = :add
|
25
|
-
end
|
26
|
-
|
27
|
-
attribute :package_name, :kind_of => String, :name_attribute => true
|
28
|
-
attribute :glob, :kind_of => String
|
29
|
-
attribute :pin, :kind_of => String
|
30
|
-
attribute :pin_priority, :kind_of => String
|