mixlib-install 0.8.0.alpha.3 → 0.8.0.alpha.4

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: 7db151f3905eb7a527cf687018366832a80a2811
4
- data.tar.gz: 6186b2ea33ee9a2809084e768a33dcb57c162f00
3
+ metadata.gz: ee7bf2631eab8ab279e49e5b34a36406f2c06d4f
4
+ data.tar.gz: 6dac3a5b06c527426617b72e360d87bdd2cac075
5
5
  SHA512:
6
- metadata.gz: fc15e3ca92d5ad638a1e9a35ff30b8cd07a88ab091b26816eaebf1de9849db3e97ec88d98c4afdd9cd78eb723276b11e90698dcdf89847a3f87379319cf6caff
7
- data.tar.gz: d98e85481f590f9e77357bfcf4223620bdfcd7ca623343b20f7a3f174e1b0350c720794b45249de50c9aafc0f964486b0b9608736f09ddeff9155a468b713aea
6
+ metadata.gz: 65405d7904b3e509d77a143d062e4761764b587dc4fac7a2ec7db9b5d6e9715a120c5bd5af552ecfe424de4eade59fff23e79ead2d80dc1a0660e290019ed1e2
7
+ data.tar.gz: 68efc9a8eb3824e14fae9591974001b51c15ed784f92f927afc1c3131cf27867eed501205a3599f094f0e67d339015036876a7346d4ca67fa173adc3d3776e5c
data/PRODUCT_MATRIX.md CHANGED
@@ -2,6 +2,7 @@
2
2
  | ------- | ------------ |
3
3
  | Analytics Platform | analytics |
4
4
  | Chef Client | chef |
5
+ | Chef Backend | chef-backend |
5
6
  | Chef Server High Availability addon | chef-ha |
6
7
  | Chef Cloud Marketplace addon | chef-marketplace |
7
8
  | Chef Server | chef-server |
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ task test: [:rubocop, :spec]
20
20
 
21
21
  desc "Run unstable channel tests"
22
22
  task "unstable" do
23
+ Rake::Task["rubocop"].invoke
23
24
  system("bundle exec rspec -t unstable")
24
25
  end
25
26
 
@@ -27,6 +27,7 @@ module Mixlib
27
27
  class Artifactory
28
28
  class ConnectionError < StandardError; end
29
29
  class AuthenticationError < StandardError; end
30
+ class NoArtifactsError < StandardError; end
30
31
 
31
32
  ENDPOINT = "http://artifactory.chef.co".freeze
32
33
 
@@ -44,50 +45,99 @@ module Mixlib
44
45
  # channel, product name, product version and platform info
45
46
  #
46
47
  def info
47
- artifacts = artifactory_info.collect { |a| create_artifact(a) }
48
-
49
- artifacts_for_version = artifacts.find_all do |a|
50
- a.version == options.resolved_version(artifacts)
48
+ artifacts = if options.latest_version?
49
+ artifactory_latest
50
+ else
51
+ artifactory_artifacts(options.product_version)
51
52
  end
52
53
 
53
54
  if options.platform
54
- artifacts_for_version.find do |a|
55
+ artifacts.select! do |a|
55
56
  a.platform == options.platform &&
56
57
  a.platform_version == options.platform_version &&
57
58
  a.architecture == options.architecture
58
59
  end
59
- else
60
- artifacts_for_version
61
60
  end
61
+
62
+ artifacts.length == 1 ? artifacts.first : artifacts
62
63
  end
63
64
 
64
- # Fetches all artifacts from the configured Artifactory repository using
65
- # channel and product name as search criteria
66
65
  #
67
- # @return [Array<Hash>] list of artifactory hash data
66
+ # Get artifacts for the latest version, channel and product_name
67
+ #
68
+ # @return [Array<ArtifactInfo>] Array of info about found artifacts
69
+ def artifactory_latest
70
+ # Get the list of builds from the REST api.
71
+ # We do this because a user in the readers group does not have
72
+ # permissions to run aql against builds.
73
+ builds = client.get("/api/build/#{options.product_name}")
74
+
75
+ if builds.nil?
76
+ raise NoArtifactsError, <<-MSG
77
+ Can not find any builds for #{options.product_name} in #{::Artifactory.endpoint}.
78
+ MSG
79
+ end
80
+
81
+ # Output we get is something like:
82
+ # {
83
+ # "buildsNumbers": [
84
+ # {"uri"=>"/12.5.1+20151213083009", "started"=>"2015-12-13T08:40:19.238+0000"},
85
+ # {"uri"=>"/12.6.0+20160111212038", "started"=>"2016-01-12T00:25:35.762+0000"},
86
+ # ...
87
+ # ]
88
+ # }
89
+ # First we sort based on started
90
+ builds["buildsNumbers"].sort_by! { |b| b["started"] }.reverse!
91
+
92
+ # Now check if the build is in the requested channel or not
93
+ # Note that if you do this for any channel other than :unstable
94
+ # it will run a high number of queries but it is fine because we
95
+ # are using artifactory only for :unstable channel
96
+ builds["buildsNumbers"].each do |build|
97
+ version = build["uri"].gsub("/", "")
98
+ artifacts = artifactory_artifacts(version)
99
+
100
+ return artifacts unless artifacts.empty?
101
+ end
102
+
103
+ # we could not find any matching artifacts
104
+ []
105
+ end
106
+
68
107
  #
69
- # Hash data:
70
- # download_uri: The full url download path
71
- # <property_name>: The names of the properties associcated to the artifact
108
+ # Get artifacts for a given version, channel and product_name
72
109
  #
73
- def artifactory_info
74
- query = <<-QUERY
110
+ # @return [Array<ArtifactInfo>] Array of info about found artifacts
111
+ def artifactory_artifacts(version)
112
+ results = artifactory_query(<<-QUERY)
75
113
  items.find(
76
114
  {"repo": "omnibus-#{options.channel}-local"},
77
- {"@omnibus.project": "#{options.product_name}"}
115
+ {"@omnibus.project": "#{options.product_name}"},
116
+ {"@omnibus.version": "#{version}"}
78
117
  ).include("repo", "path", "name", "property")
79
118
  QUERY
80
119
 
81
- results = artifactory_request do
82
- client.post("/api/search/aql", query, "Content-Type" => "text/plain")
83
- end
84
-
85
120
  # Merge artifactory properties and downloadUri to a flat Hash
86
- results["results"].collect do |result|
121
+ results.collect! do |result|
87
122
  { "downloadUri" => generate_download_uri(result) }.merge(
88
123
  map_properties(result["properties"])
89
124
  )
90
125
  end
126
+
127
+ # Convert results to build records
128
+ results.map { |a| create_artifact(a) }
129
+ end
130
+
131
+ #
132
+ # Run an artifactory query for the given query.
133
+ #
134
+ # @return [Array<Hash>] Array of results returned from artifactory
135
+ def artifactory_query(query)
136
+ results = artifactory_request do
137
+ client.post("/api/search/aql", query, "Content-Type" => "text/plain")
138
+ end
139
+
140
+ results["results"]
91
141
  end
92
142
 
93
143
  def create_artifact(artifact_map)
@@ -136,7 +136,7 @@ do_wget() {
136
136
  # do_curl URL FILENAME
137
137
  do_curl() {
138
138
  echo "trying curl..."
139
- curl -sL -D $tmp_dir/stderr "$1" > "$2"
139
+ curl --retry 5 -sL -D $tmp_dir/stderr "$1" > "$2"
140
140
  rc=$?
141
141
  # check for 404
142
142
  grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null
@@ -163,7 +163,7 @@ do_fetch() {
163
163
  return 0
164
164
  }
165
165
 
166
- # do_curl URL FILENAME
166
+ # do_perl URL FILENAME
167
167
  do_perl() {
168
168
  echo "trying perl..."
169
169
  perl -e 'use LWP::Simple; getprint($ARGV[0]);' "$1" > "$2" 2>$tmp_dir/stderr
@@ -184,7 +184,7 @@ do_perl() {
184
184
  return 0
185
185
  }
186
186
 
187
- # do_curl URL FILENAME
187
+ # do_python URL FILENAME
188
188
  do_python() {
189
189
  echo "trying python..."
190
190
  python -c "import sys,urllib2 ; sys.stdout.write(urllib2.urlopen(sys.argv[1]).read())" "$1" > "$2" 2>$tmp_dir/stderr
@@ -296,7 +296,7 @@ install_file() {
296
296
  echo "action=nocheck" >> $tmp_dir/nocheck
297
297
  echo "mail=" >> $tmp_dir/nocheck
298
298
  pkgrm -a $tmp_dir/nocheck -n $project >/dev/null 2>&1 || true
299
- pkgadd -n -d "$2" -a $tmp_dir/nocheck $project
299
+ pkgadd -G -n -d "$2" -a $tmp_dir/nocheck $project
300
300
  ;;
301
301
  "pkg")
302
302
  echo "installing with installer..."
@@ -25,7 +25,7 @@
25
25
  machine=`uname -m`
26
26
  os=`uname -s`
27
27
 
28
- if test -f "/etc/lsb-release" && grep -q DISTRIB_ID /etc/lsb-release; then
28
+ if test -f "/etc/lsb-release" && grep -q DISTRIB_ID /etc/lsb-release && ! grep -q wrlinux /etc/lsb-release; then
29
29
  platform=`grep DISTRIB_ID /etc/lsb-release | cut -d "=" -f 2 | tr '[A-Z]' '[a-z]'`
30
30
  platform_version=`grep DISTRIB_RELEASE /etc/lsb-release | cut -d "=" -f 2`
31
31
  elif test -f "/etc/debian_version"; then
@@ -75,7 +75,7 @@ module Mixlib
75
75
 
76
76
  def product_version
77
77
  if options.for_artifactory?
78
- options.resolved_version(artifacts)
78
+ artifacts.first.version
79
79
  else
80
80
  options.product_version
81
81
  end
@@ -5,7 +5,7 @@ function Get-ProjectMetadata {
5
5
  .DESCRIPTION
6
6
  Get metadata for project
7
7
  .EXAMPLE
8
- iex (new-object net.webclient).downloadstring('https:/omnitruck.chef.io/install.ps1'); Get-ProjectMetadata -project chef -channel stable
8
+ iex (new-object net.webclient).downloadstring('https://omnitruck.chef.io/install.ps1'); Get-ProjectMetadata -project chef -channel stable
9
9
 
10
10
  Gets the download url, MD5 checksum, and SHA256 checksum for the latest stable release of Chef.
11
11
  .EXAMPLE
@@ -5,7 +5,7 @@ function Get-ProjectMetadata {
5
5
  .DESCRIPTION
6
6
  Get metadata for project
7
7
  .EXAMPLE
8
- iex (new-object net.webclient).downloadstring('https:/omnitruck.chef.io/install.ps1'); Get-ProjectMetadata -project chef -channel stable
8
+ iex (new-object net.webclient).downloadstring('https://omnitruck.chef.io/install.ps1'); Get-ProjectMetadata -project chef -channel stable
9
9
 
10
10
  Gets the download url, MD5 checksum, and SHA256 checksum for the latest stable release of Chef.
11
11
  .EXAMPLE
@@ -5,7 +5,7 @@ function Install-Project {
5
5
  .DESCRIPTION
6
6
  Install a Chef Software, Inc. product
7
7
  .EXAMPLE
8
- iex (new-object net.webclient).downloadstring('https:/omnitruck.chef.io/install.ps1'); Install-Project -project chef -channel stable
8
+ iex (new-object net.webclient).downloadstring('https://omnitruck.chef.io/install.ps1'); Install-Project -project chef -channel stable
9
9
 
10
10
  Installs the latest stable version of Chef.
11
11
  .EXAMPLE
@@ -91,23 +91,6 @@ module Mixlib
91
91
  product_version.to_sym == :latest
92
92
  end
93
93
 
94
- def resolved_version(artifacts)
95
- @resolved_version ||= begin
96
- if latest_version?
97
- all_versions = artifacts.collect(&:version)
98
- # params: list of all versions, no version filtering, no pre-releases, use build version
99
- Mixlib::Versioning.find_target_version(
100
- all_versions,
101
- nil,
102
- false,
103
- true
104
- ).to_s
105
- else
106
- product_version
107
- end
108
- end
109
- end
110
-
111
94
  private
112
95
 
113
96
  def validate_product_names
@@ -155,6 +155,13 @@ PRODUCT_MATRIX = Mixlib::Install::ProductMatrix.new do
155
155
  package_name "chef"
156
156
  end
157
157
 
158
+ product "chef-backend" do
159
+ product_name "Chef Backend"
160
+ package_name "chef-backend"
161
+ ctl_command "chef-backend-ctl"
162
+ config_file "/etc/chef-backend/chef-backend.rb"
163
+ end
164
+
158
165
  product "chef-ha" do
159
166
  product_name "Chef Server High Availability addon"
160
167
  package_name "chef-ha"
@@ -220,7 +227,13 @@ PRODUCT_MATRIX = Mixlib::Install::ProductMatrix.new do
220
227
  ctl_command do |v|
221
228
  v < version_for("2.0.0") ? "opscode-manage-ctl" : "chef-manage-ctl"
222
229
  end
223
- config_file "/etc/opscode-manage/manage.rb"
230
+ config_file do |v|
231
+ if v < version_for("2.0.0")
232
+ "/etc/opscode-manage/manage.rb"
233
+ else
234
+ "/etc/chef-manage/manage.rb"
235
+ end
236
+ end
224
237
  end
225
238
 
226
239
  product "private-chef" do
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Install
3
- VERSION = "0.8.0.alpha.3"
3
+ VERSION = "0.8.0.alpha.4"
4
4
  end
5
5
  end
@@ -3,13 +3,13 @@ Function Check-UpdateChef($root, $version) {
3
3
  elseif ("$version" -eq "true") { return $false }
4
4
  elseif ("$version" -eq "latest") { return $true }
5
5
 
6
- Try { $chef_version = Get-Content $root\version-manifest.txt | select-object -1}
6
+ Try { $chef_version = (Get-Content $root\version-manifest.txt | select-object -first 1) }
7
7
  Catch {
8
- Try { $chef_version = (& $root\bin\chef-solo.bat -v).split(" ", 2)[1] }
9
- Catch { $chef_version = "" }
8
+ Try { $chef_version = (& $root\bin\chef-solo.bat -v) }
9
+ Catch { $chef_version = " " }
10
10
  }
11
11
 
12
- if ($chef_version.StartsWith($version)) { return $false }
12
+ if ($chef_version.split(" ", 2)[1].StartsWith($version)) { return $false }
13
13
  else { return $true }
14
14
  }
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-install
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.alpha.3
4
+ version: 0.8.0.alpha.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-22 00:00:00.000000000 Z
12
+ date: 2016-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: artifactory