vagabond 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. data/CHANGELOG.md +5 -0
  2. data/Vagrantfile +34 -0
  3. data/lib/vagabond/cookbooks/apt/Berksfile +8 -0
  4. data/lib/vagabond/cookbooks/apt/CHANGELOG.md +97 -0
  5. data/lib/vagabond/cookbooks/apt/CONTRIBUTING +29 -0
  6. data/lib/vagabond/cookbooks/apt/LICENSE +201 -0
  7. data/lib/vagabond/cookbooks/apt/README.md +243 -0
  8. data/lib/vagabond/cookbooks/apt/TESTING.md +25 -0
  9. data/lib/vagabond/cookbooks/apt/attributes/default.rb +4 -0
  10. data/lib/vagabond/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  11. data/lib/vagabond/cookbooks/apt/metadata.rb +30 -0
  12. data/lib/vagabond/cookbooks/apt/providers/preference.rb +61 -0
  13. data/lib/vagabond/cookbooks/apt/providers/repository.rb +132 -0
  14. data/lib/vagabond/cookbooks/apt/recipes/cacher-client.rb +59 -0
  15. data/lib/vagabond/cookbooks/apt/recipes/cacher-ng.rb +40 -0
  16. data/lib/vagabond/cookbooks/apt/recipes/default.rb +68 -0
  17. data/lib/vagabond/cookbooks/apt/resources/preference.rb +30 -0
  18. data/lib/vagabond/cookbooks/apt/resources/repository.rb +40 -0
  19. data/lib/vagabond/cookbooks/apt/templates/debian-6.0/acng.conf.erb +174 -0
  20. data/lib/vagabond/cookbooks/apt/templates/default/01proxy.erb +2 -0
  21. data/lib/vagabond/cookbooks/apt/templates/default/acng.conf.erb +276 -0
  22. data/lib/vagabond/cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +270 -0
  23. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/README.md +1 -0
  24. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/files/default/tests/minitest/cacher-ng_test.rb +28 -0
  25. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/files/default/tests/minitest/default_test.rb +28 -0
  26. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/files/default/tests/minitest/lwrps_test.rb +48 -0
  27. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/files/default/tests/minitest/support/helpers.rb +29 -0
  28. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/metadata.rb +6 -0
  29. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/recipes/cacher-ng.rb +20 -0
  30. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/recipes/default.rb +20 -0
  31. data/lib/vagabond/cookbooks/apt/test/cookbooks/apt_test/recipes/lwrps.rb +66 -0
  32. data/lib/vagabond/cookbooks/vagabond/metadata.rb +1 -0
  33. data/lib/vagabond/cookbooks/vagabond/recipes/default.rb +9 -0
  34. data/lib/vagabond/vagabond.rb +5 -1
  35. data/lib/vagabond/version.rb +1 -1
  36. data/test/Vagrantfile +48 -0
  37. data/vagabond-0.2.6.gem +0 -0
  38. data/vagabond.gemspec +1 -1
  39. metadata +36 -4
@@ -0,0 +1,25 @@
1
+ This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements.
2
+
3
+ 1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site.
4
+ 2. You must have Vagrant 1.1 installed.
5
+ 3. You must have a "sane" Ruby 1.9.3 environment.
6
+
7
+ Once the above requirements are met, install the additional requirements:
8
+
9
+ Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment.
10
+
11
+ vagrant plugin install vagrant-berkshelf
12
+ gem install berkshelf
13
+
14
+ Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version).
15
+
16
+ gem install test-kitchen --pre
17
+
18
+ Install the Vagrant driver for Test Kitchen.
19
+
20
+ gem install kitchen-vagrant
21
+
22
+ Once the above are installed, you should be able to run Test Kitchen:
23
+
24
+ kitchen list
25
+ kitchen test
@@ -0,0 +1,4 @@
1
+ default['apt']['cacher-client']['restrict_environment'] = false
2
+ default['apt']['cacher_port'] = 3142
3
+ default['apt']['key_proxy'] = ''
4
+ default['apt']['caching_server'] = false
@@ -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,30 @@
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.0.1"
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/key_proxy",
25
+ :description => "Passed as the proxy passed to GPG for the apt_repository resource",
26
+ :default => ""
27
+
28
+ attribute "apt/caching_server",
29
+ :description => "Set this to true if the node is a caching server",
30
+ :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
@@ -0,0 +1,132 @@
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
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 #{keyserver} --recv #{key}"
31
+ else
32
+ command "apt-key adv --keyserver #{keyserver} --recv #{key}"
33
+ end
34
+ action :run
35
+ not_if "apt-key list | grep #{key}"
36
+ end
37
+ end
38
+
39
+ # run command and extract gpg ids
40
+ def extract_gpg_ids_from_cmd(cmd)
41
+ so = Mixlib::ShellOut.new(cmd)
42
+ so.run_command
43
+ so.stdout.split(/\n/).collect do |t|
44
+ if z = t.match(/^pub\s+\d+\w\/([0-9A-F]{8})/)
45
+ z[1]
46
+ end
47
+ end.compact
48
+ end
49
+
50
+ # install apt key from URI
51
+ def install_key_from_uri(uri)
52
+ key_name = uri.split(/\//).last
53
+ cached_keyfile = "#{Chef::Config[:file_cache_path]}/#{key_name}"
54
+ if new_resource.key =~ /http/
55
+ remote_file cached_keyfile do
56
+ source new_resource.key
57
+ mode 00644
58
+ action :create
59
+ end
60
+ else
61
+ cookbook_file cached_keyfile do
62
+ source new_resource.key
63
+ cookbook new_resource.cookbook
64
+ mode 00644
65
+ action :create
66
+ end
67
+ end
68
+
69
+ execute "install-key #{key_name}" do
70
+ command "apt-key add #{cached_keyfile}"
71
+ action :run
72
+ not_if do
73
+ installed_ids = extract_gpg_ids_from_cmd("apt-key finger")
74
+ key_ids = extract_gpg_ids_from_cmd("gpg --with-fingerprint #{cached_keyfile}")
75
+ (installed_ids & key_ids).sort == key_ids.sort
76
+ end
77
+ end
78
+ end
79
+
80
+ # build repo file contents
81
+ def build_repo(uri, distribution, components, arch, add_deb_src)
82
+ components = components.join(' ') if components.respond_to?(:join)
83
+ repo_info = "#{uri} #{distribution} #{components}\n"
84
+ repo_info = "[arch=#{arch}] #{repo_info}" if arch
85
+ repo = "deb #{repo_info}"
86
+ repo << "deb-src #{repo_info}" if add_deb_src
87
+ repo
88
+ end
89
+
90
+ action :add do
91
+ # add key
92
+ if new_resource.keyserver && new_resource.key
93
+ install_key_from_keyserver(new_resource.key, new_resource.keyserver)
94
+ elsif new_resource.key
95
+ install_key_from_uri(new_resource.key)
96
+ end
97
+
98
+ file "/var/lib/apt/periodic/update-success-stamp" do
99
+ action :nothing
100
+ end
101
+
102
+ execute "apt-get update" do
103
+ ignore_failure true
104
+ action :nothing
105
+ end
106
+
107
+ # build repo file
108
+ repository = build_repo(new_resource.uri,
109
+ new_resource.distribution,
110
+ new_resource.components,
111
+ new_resource.arch,
112
+ new_resource.deb_src)
113
+
114
+ file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
115
+ owner "root"
116
+ group "root"
117
+ mode 00644
118
+ content repository
119
+ action :create
120
+ notifies :delete, "file[/var/lib/apt/periodic/update-success-stamp]", :immediately
121
+ notifies :run, "execute[apt-get update]", :immediately if new_resource.cache_rebuild
122
+ end
123
+ end
124
+
125
+ action :remove do
126
+ if ::File.exists?("/etc/apt/sources.list.d/#{new_resource.name}.list")
127
+ Chef::Log.info "Removing #{new_resource.name} repository from /etc/apt/sources.list.d/"
128
+ file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
129
+ action :delete
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,59 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Recipe:: cacher-client
4
+ #
5
+ # Copyright 2011, 2012 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
+ #remove Acquire::http::Proxy lines from /etc/apt/apt.conf since we use 01proxy
21
+ #these are leftover from preseed installs
22
+ execute 'Remove proxy from /etc/apt/apt.conf' do
23
+ command "sed --in-place '/^Acquire::http::Proxy/d' /etc/apt/apt.conf"
24
+ only_if "grep Acquire::http::Proxy /etc/apt/apt.conf"
25
+ end
26
+
27
+ servers = []
28
+ if node['apt'] && node['apt']['cacher_ipaddress']
29
+ cacher = Chef::Node.new
30
+ cacher.name(node['apt']['cacher_ipaddress'])
31
+ cacher.set['ipaddress'] = node['apt']['cacher_ipaddress']
32
+ servers << cacher
33
+ end
34
+
35
+ unless Chef::Config[:solo]
36
+ query = "apt_caching_server:true NOT name:#{node.name}"
37
+ query += " AND chef_environment:#{node.chef_environment}" if node['apt']['cacher-client']['restrict_environment']
38
+ Chef::Log.debug("apt::cacher-client searching for '#{query}'")
39
+ servers += search(:node, query)
40
+ end
41
+
42
+ if servers.length > 0
43
+ Chef::Log.info("apt-cacher-ng server found on #{servers[0]}.")
44
+ template '/etc/apt/apt.conf.d/01proxy' do
45
+ source '01proxy.erb'
46
+ owner 'root'
47
+ group 'root'
48
+ mode 00644
49
+ variables(
50
+ :proxy => servers[0]['ipaddress'],
51
+ :port => node['apt']['cacher_port']
52
+ )
53
+ end.run_action(:create)
54
+ else
55
+ Chef::Log.info('No apt-cacher-ng server found.')
56
+ file '/etc/apt/apt.conf.d/01proxy' do
57
+ action :delete
58
+ end
59
+ end
@@ -0,0 +1,40 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Recipe:: cacher-ng
4
+ #
5
+ # Copyright 2008-2012, 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
+ template "/etc/apt-cacher-ng/acng.conf" do
27
+ source "acng.conf.erb"
28
+ owner "root"
29
+ group "root"
30
+ mode 00644
31
+ notifies :restart, "service[apt-cacher-ng]"
32
+ end
33
+
34
+ service "apt-cacher-ng" do
35
+ supports :restart => true, :status => false
36
+ action [:enable, :start]
37
+ end
38
+
39
+ #this will help seed the proxy
40
+ include_recipe "apt::cacher-client"
@@ -0,0 +1,68 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2008-2011, 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
+ # Run apt-get update to create the stamp file
22
+ execute "apt-get-update" do
23
+ command "apt-get update"
24
+ ignore_failure true
25
+ not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end
26
+ end
27
+
28
+ # For other recipes to call to force an update
29
+ execute "apt-get update" do
30
+ command "apt-get update"
31
+ ignore_failure true
32
+ action :nothing
33
+ end
34
+
35
+ # Automatically remove packages that are no longer needed for dependencies
36
+ execute "apt-get autoremove" do
37
+ command "apt-get -y autoremove"
38
+ action :nothing
39
+ end
40
+
41
+ # Automatically remove .deb files for packages no longer on your system
42
+ execute "apt-get autoclean" do
43
+ command "apt-get -y autoclean"
44
+ action :nothing
45
+ end
46
+
47
+ # provides /var/lib/apt/periodic/update-success-stamp on apt-get update
48
+ package "update-notifier-common" do
49
+ notifies :run, 'execute[apt-get-update]', :immediately
50
+ end
51
+
52
+ execute "apt-get-update-periodic" do
53
+ command "apt-get update"
54
+ ignore_failure true
55
+ only_if do
56
+ ::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
57
+ ::File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
58
+ end
59
+ end
60
+
61
+ %w{/var/cache/local /var/cache/local/preseeding}.each do |dirname|
62
+ directory dirname do
63
+ owner "root"
64
+ group "root"
65
+ mode 00755
66
+ action :create
67
+ end
68
+ end