knife-pkg 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/Vagrantfile +16 -0
- data/lib/chef/knife/pkg_base.rb +19 -10
- data/lib/chef/knife/pkg_install_updates.rb +8 -2
- data/lib/chef/knife/pkg_show_updates.rb +7 -1
- data/lib/knife-pkg/controllers/debian.rb +13 -10
- data/lib/knife-pkg/controllers/package_controller.rb +10 -1
- data/lib/knife-pkg/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef5dd85d6dfea7ed525de94598be3975ee647056
|
4
|
+
data.tar.gz: 4c8ed9c2fcabd22f44e1dd36d73168a024c60e20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cf31489b4112015c47590125510991e0b6352e1bfa53a42febe6453c07e965d2a8497c53b02d4451d3c48f58e1af3b8828b0eca6ce8c99b1253af0efe154f6e
|
7
|
+
data.tar.gz: 275a7d8f6f2e6522d39bbe10d39ae70ccddadd947ce1da1bd78d1a528980cc66b026beb2f7a2880191c25e8b69f0811b1b6c939f2f710ffd2de4ffa88f0846f7
|
data/README.md
CHANGED
@@ -83,8 +83,10 @@ $ knife pkg install updates "roles:webserver" -U "libxml2,gpgv,gnupg"
|
|
83
83
|
|
84
84
|
## Requirements
|
85
85
|
|
86
|
-
* Chef(-Server) or anything else which supports `search(:node, "*:*")`
|
87
86
|
* SSH access
|
87
|
+
* Chef(-Server) or anything else which supports `search(:node, "*:*")` (*not required when you use `-m`*)
|
88
|
+
* when `-m` option is given, `ohai` has to be installed on the node
|
89
|
+
|
88
90
|
|
89
91
|
## Installation
|
90
92
|
|
data/Vagrantfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
boxes = {
|
2
|
+
:debian => { :image => "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_debian-7.1.0_provisionerless.box" },
|
3
|
+
:ubuntu => { :image => "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box" }
|
4
|
+
}
|
5
|
+
|
6
|
+
Vagrant::configure("2") do |config|
|
7
|
+
boxes.each do |name, options|
|
8
|
+
config.omnibus.chef_version = 'latest'
|
9
|
+
config.berkshelf.enabled = false
|
10
|
+
|
11
|
+
config.vm.define name do |box_config|
|
12
|
+
box_config.vm.box = name.to_s
|
13
|
+
box_config.vm.box_url = options[:image]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/chef/knife/pkg_base.rb
CHANGED
@@ -21,7 +21,6 @@ class Chef
|
|
21
21
|
def run
|
22
22
|
# necessary for Knife::Ssh
|
23
23
|
@longest = 0
|
24
|
-
config[:manual] = false
|
25
24
|
|
26
25
|
configure_attribute
|
27
26
|
configure_sudo
|
@@ -53,6 +52,7 @@ class Chef
|
|
53
52
|
node = node_by_hostname(server.host)
|
54
53
|
if node
|
55
54
|
cur_session = server.session(true)
|
55
|
+
ui.info("===> " + hostname_by_attribute(node))
|
56
56
|
process(node, cur_session)
|
57
57
|
cur_session.close
|
58
58
|
else
|
@@ -69,22 +69,31 @@ class Chef
|
|
69
69
|
|
70
70
|
def node_by_hostname(hostname)
|
71
71
|
node = nil
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
if config[:manual]
|
73
|
+
obj = Struct.new(:fqdn)
|
74
|
+
node = obj.new(hostname)
|
75
|
+
else
|
76
|
+
@action_nodes.each do |n|
|
77
|
+
if hostname_by_attribute(n) == hostname
|
78
|
+
node = n
|
79
|
+
break
|
80
|
+
end
|
76
81
|
end
|
77
82
|
end
|
78
83
|
node
|
79
84
|
end
|
80
85
|
|
81
86
|
def hostname_by_attribute(node)
|
82
|
-
if
|
83
|
-
|
84
|
-
elsif config[:override_attribute]
|
85
|
-
i = extract_nested_value(node, config[:override_attribute])
|
87
|
+
if config[:manual]
|
88
|
+
node[:fqdn]
|
86
89
|
else
|
87
|
-
|
90
|
+
if !config[:override_attribute] && node[:cloud] and node[:cloud][:public_hostname]
|
91
|
+
i = node[:cloud][:public_hostname]
|
92
|
+
elsif config[:override_attribute]
|
93
|
+
i = extract_nested_value(node, config[:override_attribute])
|
94
|
+
else
|
95
|
+
i = extract_nested_value(node, config[:attribute])
|
96
|
+
end
|
88
97
|
end
|
89
98
|
end
|
90
99
|
end
|
@@ -93,13 +93,19 @@ class Chef
|
|
93
93
|
:proc => Proc.new { |pkgs| pkgs.split(',') },
|
94
94
|
:default => Array.new
|
95
95
|
|
96
|
+
option :manual,
|
97
|
+
:short => "-m",
|
98
|
+
:long => "--manual-list",
|
99
|
+
:boolean => true,
|
100
|
+
:description => "QUERY is a space separated list of servers",
|
101
|
+
:default => false
|
102
|
+
|
103
|
+
|
96
104
|
def run
|
97
105
|
super
|
98
106
|
end
|
99
107
|
|
100
108
|
def process(node, session)
|
101
|
-
ui.info("===> " + extract_nested_value(node, config[:attribute]))
|
102
|
-
|
103
109
|
::Knife::Pkg::PackageController.update!(node, session, config[:updates], pkg_options)
|
104
110
|
end
|
105
111
|
end
|
@@ -86,13 +86,19 @@ class Chef
|
|
86
86
|
:boolean => true,
|
87
87
|
:default => false
|
88
88
|
|
89
|
+
option :manual,
|
90
|
+
:short => "-m",
|
91
|
+
:long => "--manual-list",
|
92
|
+
:boolean => true,
|
93
|
+
:description => "QUERY is a space separated list of servers",
|
94
|
+
:default => false
|
95
|
+
|
89
96
|
|
90
97
|
def run
|
91
98
|
super
|
92
99
|
end
|
93
100
|
|
94
101
|
def process(node, session)
|
95
|
-
ui.info("===> " + extract_nested_value(node, config[:attribute]))
|
96
102
|
::Knife::Pkg::PackageController.available_updates(node, session, pkg_options)
|
97
103
|
end
|
98
104
|
end
|
@@ -29,6 +29,8 @@ module Knife
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def last_pkg_cache_update
|
32
|
+
raise_update_notifier_missing! unless update_notifier_installed?
|
33
|
+
|
32
34
|
result = ShellCommand.exec("stat -c %y /var/lib/apt/periodic/update-success-stamp", @session)
|
33
35
|
Time.parse(result.stdout.chomp)
|
34
36
|
end
|
@@ -39,15 +41,12 @@ module Knife
|
|
39
41
|
|
40
42
|
def available_updates
|
41
43
|
packages = Array.new
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
package.version = installed_version(package)
|
49
|
-
packages << package
|
50
|
-
end
|
44
|
+
raise_update_notifier_missing! unless update_notifier_installed?
|
45
|
+
result = ShellCommand.exec("#{sudo}/usr/lib/update-notifier/apt_check.py -p", @session)
|
46
|
+
result.stderr.split("\n").each do |item|
|
47
|
+
package = Package.new(item)
|
48
|
+
package.version = installed_version(package)
|
49
|
+
packages << package
|
51
50
|
end
|
52
51
|
packages
|
53
52
|
end
|
@@ -59,7 +58,11 @@ module Knife
|
|
59
58
|
end
|
60
59
|
|
61
60
|
def update_notifier_installed?
|
62
|
-
|
61
|
+
ShellCommand.exec("dpkg-query -W update-notifier-common 2>/dev/null || echo 'false'", @session).stdout.chomp != 'false'
|
62
|
+
end
|
63
|
+
|
64
|
+
def raise_update_notifier_missing!
|
65
|
+
raise RuntimeError, "No update-notifier(-common) installed!? Install it and try again!"
|
63
66
|
end
|
64
67
|
end
|
65
68
|
end
|
@@ -148,7 +148,12 @@ module Knife
|
|
148
148
|
|
149
149
|
def self.init_controller(node, session, opts)
|
150
150
|
begin
|
151
|
-
ctrl_name =
|
151
|
+
ctrl_name = ''
|
152
|
+
if node.respond_to?(:platform)
|
153
|
+
ctrl_name = self.controller_name(node.platform)
|
154
|
+
else
|
155
|
+
ctrl_name = self.platform_by_local_ohai(session, opts)
|
156
|
+
end
|
152
157
|
require File.join(File.dirname(__FILE__), ctrl_name)
|
153
158
|
rescue LoadError
|
154
159
|
raise NotImplementedError, "I'm sorry, but #{node.platform} is not supported!"
|
@@ -158,6 +163,10 @@ module Knife
|
|
158
163
|
ctrl
|
159
164
|
end
|
160
165
|
|
166
|
+
def self.platform_by_local_ohai(session, opts)
|
167
|
+
ShellCommand.exec("ohai platform| grep \\\"", session).stdout.strip.gsub(/\"/,'')
|
168
|
+
end
|
169
|
+
|
161
170
|
def self.controller_name(platform)
|
162
171
|
case platform
|
163
172
|
when 'debian', 'ubuntu'
|
data/lib/knife-pkg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-pkg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Holger Amann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- LICENSE.txt
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
|
+
- Vagrantfile
|
82
83
|
- knife-pkg.gemspec
|
83
84
|
- lib/chef/knife/pkg_base.rb
|
84
85
|
- lib/chef/knife/pkg_install_updates.rb
|