pe_info 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4489b5366f96844f0c511030e49986133d224e7e
4
- data.tar.gz: 2ab2613f979ddaeb6c8030f72cd0503bbe68c952
3
+ metadata.gz: 405b7419cedb6fd7824e1ea75c51e4130b60ffa6
4
+ data.tar.gz: 894e5b64f54de79f9550ad741c1635f1988a72b5
5
5
  SHA512:
6
- metadata.gz: e65248cebe0cd9c7eed9c49b025364373b3fc6d0116dbe66efbcc7d0edc7e1b0ba0a8c2659bd33dac0ba95fa5347038f6d0670c14098a834e2fff34126cf53d5
7
- data.tar.gz: 2a6e516f1e91b9654d2153921fd958c7e119f858933e43848bd95e70cd6f2640ce49979a3106bc58d2cee46331afe97608a3d8d568f886063760af1dc05b85f3
6
+ metadata.gz: 75b4b58d09ca21bb1e9246baaecabd441acece276eaed84e5322b1e7e0fa389ab1ecc40b71f8886f5bf2b9214247ecd07797bc5b40feb93df0f021fb1194aa5d
7
+ data.tar.gz: 4d13f9142e94ed0d3d392d5e441507c42dadc4e40022ecd8708ce40fd51a222e1e676f2cbaf78421cd31aa0aa8a3c2dcf10e65895f32dee2bbac132040c1e105
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /pkg/
9
9
  /spec/reports/
10
10
  /tmp/
11
+ /.idea
@@ -14,6 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  require "pe_info/version"
17
+ require "tmpdir"
17
18
 
18
19
  module PeInfo
19
20
  module Tarball
@@ -53,9 +54,49 @@ module PeInfo
53
54
  agent_version
54
55
  end
55
56
 
56
- def self.inspect(tarball)
57
- pe_version = false
58
- agent_version = false
57
+ def self.supported_platforms_from_dir(pe_modules_dir)
58
+ platforms = []
59
+ Dir.chdir(pe_modules_dir) do
60
+ Dir.chdir("opt/puppetlabs/puppet/modules/pe_repo/manifests/platform") do
61
+ # windows doesn't use the platform tag...
62
+ manifests = Dir.glob("*.pp").reject {|e| e =~ /windows/ }
63
+ manifests.each { |f|
64
+ pe_repo_match = File.open(f).grep(/^\s+pe_repo::/)
65
+ if pe_repo_match.length > 0
66
+ # need to read the call the manifest would have made to get the
67
+ # platform tag, eg ubuntu-1604-i386 is really ubuntu-16.04-i386...
68
+ platforms << pe_repo_match[0].scan(/[^']+'([^']+)':/)
69
+ else
70
+ # some manifests dont have installers any more... (skipped)
71
+ end
72
+ }
73
+ end
74
+ end
75
+
76
+ # scan seems to wrap elements in arrays..
77
+ platforms.flatten.sort
78
+ end
79
+
80
+ def self.supported_platforms(tarball, fail_bad_tarball=true)
81
+ platforms = false
82
+ Dir.mktmpdir do |temp_dir|
83
+ Dir.chdir(temp_dir) do
84
+ if system("#{tar} --strip-components 3 -zxvf #{tarball} --wildcards puppet-enterprise*/packages/*/pe-modules*.rpm && rpm2cpio pe-modules*.rpm | cpio -idmv")
85
+ platforms = supported_platforms_from_dir(temp_dir)
86
+ elsif fail_bad_tarball
87
+ raise "Tarball error - not found or missing .rpm"
88
+ end
89
+
90
+ end
91
+ end
92
+ platforms
93
+ end
94
+
95
+ # @param fail_bad_tarball False to ignore bad tarballs and proceed (for testing)
96
+ def self.inspect(tarball, fail_bad_tarball=true)
97
+ pe_version = false
98
+ agent_version = false
99
+ supported_platforms = []
59
100
 
60
101
  if is_pe_tarball(tarball)
61
102
  if File.exists?(tarball)
@@ -65,13 +106,17 @@ module PeInfo
65
106
 
66
107
  # look for the agent version
67
108
  agent_version = agent_version(tarball)
109
+
110
+ # Extract the pe-modules*rpm from the tarball and scan it supported
111
+ # platforms in puppet code
112
+ supported_platforms = supported_platforms(tarball, fail_bad_tarball)
68
113
  else
69
114
  PeInfo.logger.debug "File not found: #{tarball}"
70
115
  end
71
116
  else
72
117
  PeInfo.logger.debug "Not a puppet install tarball: #{tarball}"
73
118
  end
74
- return pe_version, agent_version
119
+ return pe_version, agent_version, supported_platforms
75
120
  end
76
121
  end
77
122
  end
@@ -14,5 +14,5 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  module PeInfo
17
- VERSION = "0.1.6"
17
+ VERSION = "0.2.0"
18
18
  end
data/pe_info.gemspec CHANGED
@@ -6,13 +6,13 @@ require 'pe_info/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "pe_info"
8
8
  spec.version = PeInfo::VERSION
9
- spec.authors = ["Geoff Williams"]
10
- spec.email = ["geoff.williams@puppet.com"]
9
+ spec.authors = ["Declarative Systems"]
10
+ spec.email = ["sales@declarativesystems.com"]
11
11
 
12
12
  spec.summary = %q{Get info about a PE installation tarball}
13
13
  spec.description = %q{Peek inside a Puppet Enterprise tarball to lookup versions and capabilities}
14
- spec.homepage = "https://github.com/GeoffWilliams/pe_info"
15
- spec.license = "Apache 2.0"
14
+ spec.homepage = "https://github.com/declarativesystems/pe_info"
15
+ spec.license = "Apache-2.0"
16
16
 
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pe_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Geoff Williams
7
+ - Declarative Systems
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-21 00:00:00.000000000 Z
11
+ date: 2017-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '3.0'
55
55
  description: Peek inside a Puppet Enterprise tarball to lookup versions and capabilities
56
56
  email:
57
- - geoff.williams@puppet.com
57
+ - sales@declarativesystems.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
@@ -73,9 +73,9 @@ files:
73
73
  - lib/pe_info/tarball.rb
74
74
  - lib/pe_info/version.rb
75
75
  - pe_info.gemspec
76
- homepage: https://github.com/GeoffWilliams/pe_info
76
+ homepage: https://github.com/declarativesystems/pe_info
77
77
  licenses:
78
- - Apache 2.0
78
+ - Apache-2.0
79
79
  metadata: {}
80
80
  post_install_message:
81
81
  rdoc_options: []
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.5.2
96
+ rubygems_version: 2.5.2
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Get info about a PE installation tarball