kitchen-habitat-config 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +153 -0
- data/kitchen-habitat.gemspec +38 -0
- data/lib/kitchen-habitat/version.rb +5 -0
- data/lib/kitchen/provisioner/habitat.rb +337 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5d827805ebbab6bc3db302384f92bff7c1a1610dc7dd32a6a6f52f27505a4aa7
|
4
|
+
data.tar.gz: cc8957e1f7fd71f75504e62fd3ff671ade16e2c14437e55908c9f25007d3e305
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: abef29edd561dbe7442dd923be831c38eec7e1220bc48171478fabf416d967b3688708a0517f2b0afa317d62ee4941ee169c481cc2ce922b8e89937e4c513d8c
|
7
|
+
data.tar.gz: c04c5fcea8007b1d6d61b2ab2d55a9a59a32c48c3d3a230d195cf542862906e708678eb788e54746562605b918623e0222c042e6989274a9aaaa8e990eadfdfa
|
data/README.md
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/kitchen-habitat.svg)](http://badge.fury.io/rb/kitchen-habitat)
|
2
|
+
|
3
|
+
# kitchen-habitat
|
4
|
+
A Test Kitchen Provisioner for [Habitat](https://habitat.sh)
|
5
|
+
|
6
|
+
## Requirements
|
7
|
+
|
8
|
+
|
9
|
+
## Installation & Setup
|
10
|
+
You'll need the test-kitchen & kitchen-habitat gems installed in your system, along with kitchen-vagrant or some other suitable driver for test-kitchen.
|
11
|
+
|
12
|
+
## Configuration Settings
|
13
|
+
|
14
|
+
### Depot settings
|
15
|
+
|
16
|
+
* `depot_url`
|
17
|
+
* Target Habitat Depot to use to install packages.
|
18
|
+
* Defaults to `nil` (which will use the default depot settings for the `hab` CLI from ~/.hab/etc/cli.toml).
|
19
|
+
|
20
|
+
### Supervisor Settings
|
21
|
+
|
22
|
+
* `hab_sup_origin`
|
23
|
+
* Package identification for the supervisor to use.
|
24
|
+
* Defaults to `core`, or, if `hab_sup_artifact_name` is supplied, the `hab_sup_origin` will be parsed from the filename of the hart file.
|
25
|
+
* `hab_sup_name`
|
26
|
+
* Name of the supervisor package
|
27
|
+
* Defaults to `hab-sup`, or, if `hab_sup_artifact_name` is supplied, the `hab_sup_name` will be parsed from the filename of the hart file.
|
28
|
+
* `hab_sup_version`
|
29
|
+
* Version number of `hab-sup` to run
|
30
|
+
* Defaults to `nil`, or, if `hab_sup_artifact_name` is supplied, the `hab_sup_version` will be parsed from the filename of the hart file.
|
31
|
+
* `hab_sup_release`
|
32
|
+
* Release of the `hab-sup` package to run
|
33
|
+
* Defaults to `nil`, or, if `hab_sup_artifact_name` is supplied, the `hab_sup_release` will be parsed from the filename of the hart file.
|
34
|
+
* `hab_sup_artifact_name`
|
35
|
+
* Artifact package name for a custom supervisor to run
|
36
|
+
* Used to upload and test a local supervisor.
|
37
|
+
* Package should be located in the `results_directory`
|
38
|
+
* Defaults to `nil
|
39
|
+
* `hab_sup_listen_http`
|
40
|
+
* Port for the supervisor's sidecar to listen on.
|
41
|
+
* Defaults to `nil`
|
42
|
+
* `hab_sup_listen_gossip`
|
43
|
+
* Port for the supervisor's gossip communication
|
44
|
+
* Defaults to `nil`
|
45
|
+
* `hab_sup_group`
|
46
|
+
* Service group for the supervisor to belong do.
|
47
|
+
* Default is `default`
|
48
|
+
* `hab_sup_bind`
|
49
|
+
* Service group for the supervisor to bind to.
|
50
|
+
* Default is `[]`
|
51
|
+
* `hab_sup_peer`
|
52
|
+
* IP and port (e.g. `192.168.1.86:9010`) of the supervisor of which to connect to join the ring.
|
53
|
+
* Default is `[]`
|
54
|
+
|
55
|
+
### Package Settings
|
56
|
+
|
57
|
+
* `artifact_name`
|
58
|
+
* Artifact package filename to install and run.
|
59
|
+
* Used to upload and test a local artifact.
|
60
|
+
* Package should be located in the `results_directory`
|
61
|
+
* Example - `core-jq-static-1.5-20170127185151-x86_64-linux.hart`
|
62
|
+
* Defaults to `nil`
|
63
|
+
* `results_directory`
|
64
|
+
* Directory (relative to the location of the .kitchen.yml) containing package artifacts (harts) to copy to the remote system
|
65
|
+
* Defaults to checking the local directory for a `results` directory, then its parent (`../results`) and grandparent (`../../results`), which should accomodate most studio layouts.
|
66
|
+
* `package_origin`
|
67
|
+
* Origin for the package to run.
|
68
|
+
* Defaults to `core`, or, if `artifact_name` is supplied, the `package_origin` will be parsed from the filename of the hart file.
|
69
|
+
* `package_name`
|
70
|
+
* Package name for the supervisor to run.
|
71
|
+
* Defaults to the suite name or, if `artifact_name` is supplied, the `package_name` will be parsed from the filename of the hart file.
|
72
|
+
* `package_version`
|
73
|
+
* Package version of the package to be run.
|
74
|
+
* Defaults to `nil` or if `artifact_name` is supplied, the `package_version` will be parsed from the filename of the hart file.
|
75
|
+
* `package_release`
|
76
|
+
* Package release of the package to be run.
|
77
|
+
* Defaults to `nil` or if `artifact_name` is supplied, the `package_release` will be parsed from the filename of the hart file.
|
78
|
+
* `service_topology`
|
79
|
+
* The topology for the service to run in. Valid values are `nil`, `standalone`, `leader`
|
80
|
+
* Defaults to `nil` which is `standalone`
|
81
|
+
* `service_update_strategy`
|
82
|
+
* Describes how package updates are to be applied. Valid values are `nil`, `at-once`, `rolling`.
|
83
|
+
* Default is `nil`, which does not check for package updates.
|
84
|
+
* `config_directory`
|
85
|
+
* Directory containing a user.toml or/and a default.toml, hooks, and configuration files to be passed to the service under test.
|
86
|
+
* Defaults to `nil`
|
87
|
+
* `override_package_config`
|
88
|
+
* Tell the supervisor to load the the configuration files and hooks from `config_directory` instead of what was packaged with the service. (Uses `--config-from` via the `hab-sup` CLI.)
|
89
|
+
* `user_toml_name`
|
90
|
+
* Name of the file to be used as the user.toml for the service under test.
|
91
|
+
* Defaults to `user.toml`
|
92
|
+
* `install_latest_artifact`
|
93
|
+
* Choose to install latest artifact.
|
94
|
+
* Must specify `artifact_name` or `package_origin` and `package_name`
|
95
|
+
* `package_version` and `package_release` will be ignored
|
96
|
+
* Defaults to `false`
|
97
|
+
|
98
|
+
## Examples
|
99
|
+
|
100
|
+
Run the core-redis package
|
101
|
+
|
102
|
+
```yaml
|
103
|
+
driver:
|
104
|
+
name: vagrant
|
105
|
+
|
106
|
+
provisioner:
|
107
|
+
name: habitat
|
108
|
+
hab_sup_origin: core
|
109
|
+
hab_sup_name: sup
|
110
|
+
package_origin: core
|
111
|
+
package_name: redis
|
112
|
+
|
113
|
+
platforms:
|
114
|
+
- name: ubuntu-16.04
|
115
|
+
|
116
|
+
suites:
|
117
|
+
- name: default
|
118
|
+
```
|
119
|
+
|
120
|
+
Two node: elasticsearch and kibana
|
121
|
+
|
122
|
+
```yaml
|
123
|
+
driver:
|
124
|
+
name: docker
|
125
|
+
|
126
|
+
provisioner:
|
127
|
+
name: habitat
|
128
|
+
hab_sup_origin: core
|
129
|
+
hab_sup_name: sup
|
130
|
+
|
131
|
+
platforms:
|
132
|
+
- name: ubuntu-16.04
|
133
|
+
|
134
|
+
suites:
|
135
|
+
- name: elasticsearch
|
136
|
+
provisioner:
|
137
|
+
package_origin: core
|
138
|
+
package_name: elasticsearch
|
139
|
+
driver:
|
140
|
+
instance_name: elastic
|
141
|
+
|
142
|
+
- name: kibana
|
143
|
+
provisioner:
|
144
|
+
package_origin: core
|
145
|
+
package_name: kibana
|
146
|
+
hab_sup_peer:
|
147
|
+
- elastic
|
148
|
+
hab_sup_bind:
|
149
|
+
- elasticsearch:elasticsearch.default
|
150
|
+
driver:
|
151
|
+
instance_name: kibana
|
152
|
+
links: elastic:elastic
|
153
|
+
```
|
@@ -0,0 +1,38 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "kitchen-habitat/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "kitchen-habitat-config"
|
6
|
+
s.version = Kitchen::Habitat::VERSION
|
7
|
+
s.authors = ["Steven Murawski"]
|
8
|
+
s.email = ["smurawski@chef.io"]
|
9
|
+
s.homepage = "https://github.com/test-kitchen/kitchen-habitat"
|
10
|
+
s.summary = "Habitat provisioner for test-kitchen"
|
11
|
+
candidates = Dir.glob("lib/**/*") + ["README.md", "kitchen-habitat.gemspec"]
|
12
|
+
s.files = candidates.sort
|
13
|
+
s.platform = Gem::Platform::RUBY
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.rubyforge_project = "[none]"
|
16
|
+
s.license = "Apache 2"
|
17
|
+
s.description = <<-EOF
|
18
|
+
== DESCRIPTION:
|
19
|
+
|
20
|
+
Habitat Provisioner for Test Kitchen
|
21
|
+
|
22
|
+
== FEATURES:
|
23
|
+
|
24
|
+
TBD
|
25
|
+
|
26
|
+
EOF
|
27
|
+
s.add_dependency "test-kitchen", "~> 1.4"
|
28
|
+
|
29
|
+
s.add_development_dependency "countloc", "~> 0.4"
|
30
|
+
s.add_development_dependency "rake"
|
31
|
+
s.add_development_dependency "rspec", "~> 3.2"
|
32
|
+
s.add_development_dependency "simplecov", "~> 0.9"
|
33
|
+
|
34
|
+
# style and complexity libraries are tightly version pinned as newer releases
|
35
|
+
# may introduce new and undesireable style choices which would be immediately
|
36
|
+
# enforced in CI
|
37
|
+
s.add_development_dependency "chefstyle"
|
38
|
+
end
|
@@ -0,0 +1,337 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Steven Murawski (<steven.murawski@gmail.com>)
|
3
|
+
#
|
4
|
+
# Copyright (C) 2017 Steven Murawski
|
5
|
+
#
|
6
|
+
# Licensed under the MIT License.
|
7
|
+
# See LICENSE for more details
|
8
|
+
|
9
|
+
require 'fileutils'
|
10
|
+
require 'pathname'
|
11
|
+
require 'kitchen/provisioner/base'
|
12
|
+
require 'kitchen/util'
|
13
|
+
|
14
|
+
module Kitchen
|
15
|
+
module Provisioner
|
16
|
+
class Habitat < Base
|
17
|
+
kitchen_provisioner_api_version 2
|
18
|
+
|
19
|
+
default_config :depot_url, nil
|
20
|
+
default_config :hab_sup_origin, 'core'
|
21
|
+
default_config :hab_sup_name, 'hab-sup'
|
22
|
+
default_config :hab_sup_version, nil
|
23
|
+
default_config :hab_sup_release, nil
|
24
|
+
default_config :hab_sup_artifact_name, nil
|
25
|
+
|
26
|
+
# hab-sup manager options
|
27
|
+
default_config :hab_sup_listen_http, nil
|
28
|
+
default_config :hab_sup_listen_gossip, nil
|
29
|
+
default_config :hab_sup_peer, []
|
30
|
+
default_config :hab_sup_bind, []
|
31
|
+
default_config :hab_sup_group, nil
|
32
|
+
|
33
|
+
# hab-sup service options
|
34
|
+
default_config :install_latest_artifact, false
|
35
|
+
default_config :artifact_name, nil
|
36
|
+
default_config :package_origin, 'core'
|
37
|
+
default_config :package_name
|
38
|
+
default_config :package_version, nil
|
39
|
+
default_config :package_release, nil
|
40
|
+
default_config :service_topology, nil
|
41
|
+
default_config :service_update_strategy, nil
|
42
|
+
default_config :channel, 'stable'
|
43
|
+
|
44
|
+
# local stuffs to copy
|
45
|
+
default_config :results_directory, nil
|
46
|
+
default_config :config_directory, nil
|
47
|
+
default_config :user_toml_name, 'user.toml'
|
48
|
+
default_config :override_package_config, false
|
49
|
+
|
50
|
+
# experimental
|
51
|
+
default_config :use_screen, false
|
52
|
+
|
53
|
+
def finalize_config!(instance)
|
54
|
+
# Check to see if a package ident was specified for package name and be helpful
|
55
|
+
unless config[:package_name].nil? || (config[:package_name] =~ /\//).nil?
|
56
|
+
config[:package_origin], config[:package_name], config[:package_version], config[:package_release] = config[:package_name].split('/')
|
57
|
+
end
|
58
|
+
|
59
|
+
unless config[:hab_sup_artifact_name].nil?
|
60
|
+
ident = artifact_name_to_package_ident_regex.match(config[:hab_sup_artifact_name])
|
61
|
+
config[:hab_sup_origin] = ident['origin']
|
62
|
+
config[:hab_sup_name] = ident['name']
|
63
|
+
config[:hab_sup_version] = ident['version']
|
64
|
+
config[:hab_sup_release] = ident['release']
|
65
|
+
end
|
66
|
+
|
67
|
+
unless config[:artifact_name].nil?
|
68
|
+
ident = artifact_name_to_package_ident_regex.match(config[:artifact_name])
|
69
|
+
config[:package_origin] = ident['origin']
|
70
|
+
config[:package_name] = ident['name']
|
71
|
+
config[:package_version] = ident['version']
|
72
|
+
config[:package_release] = ident['release']
|
73
|
+
end
|
74
|
+
super(instance)
|
75
|
+
end
|
76
|
+
|
77
|
+
def install_command
|
78
|
+
raise "Need to fill in some implementation here." if instance.platform == "windows"
|
79
|
+
wrap_shell_code <<-BASH
|
80
|
+
#{export_hab_origin}
|
81
|
+
if command -v hab >/dev/null 2>&1
|
82
|
+
then
|
83
|
+
echo "Habitat CLI already installed."
|
84
|
+
else
|
85
|
+
curl 'https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh' | sudo bash
|
86
|
+
fi
|
87
|
+
BASH
|
88
|
+
end
|
89
|
+
|
90
|
+
def init_command
|
91
|
+
wrap_shell_code <<-EOH
|
92
|
+
id -u hab >/dev/null 2>&1 || sudo useradd hab >/dev/null 2>&1
|
93
|
+
rm -rf /tmp/kitchen
|
94
|
+
mkdir -p /tmp/kitchen/results
|
95
|
+
#{'mkdir -p /tmp/kitchen/config' unless config[:override_package_config]}
|
96
|
+
EOH
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_sandbox
|
100
|
+
super
|
101
|
+
copy_results_to_sandbox
|
102
|
+
copy_user_toml_to_sandbox
|
103
|
+
copy_package_config_from_override_to_sandbox
|
104
|
+
end
|
105
|
+
|
106
|
+
def prepare_command
|
107
|
+
wrap_shell_code <<-EOH
|
108
|
+
#{export_hab_origin}
|
109
|
+
#{install_supervisor_command}
|
110
|
+
#{binlink_supervisor_command}
|
111
|
+
#{install_service_package}
|
112
|
+
#{remove_previous_user_toml}
|
113
|
+
#{copy_user_toml_to_service_directory}
|
114
|
+
EOH
|
115
|
+
end
|
116
|
+
|
117
|
+
def run_command
|
118
|
+
run = <<-RUN
|
119
|
+
#{export_hab_origin}
|
120
|
+
#{clean_up_screen_sessions}
|
121
|
+
#{clean_up_previous_supervisor}
|
122
|
+
echo "Running #{package_ident}."
|
123
|
+
sudo hab pkg install #{package_ident}
|
124
|
+
#{run_package_in_background}
|
125
|
+
RUN
|
126
|
+
|
127
|
+
wrap_shell_code run
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
def clean_up_screen_sessions
|
133
|
+
return unless config[:use_screen]
|
134
|
+
<<-CLEAN
|
135
|
+
if sudo screen -ls | grep -q #{clean_package_name}
|
136
|
+
then
|
137
|
+
echo "Killing previous supervisor session."
|
138
|
+
sudo screen -S \"#{clean_package_name}\" -X quit > /dev/null
|
139
|
+
echo "Removing dead session."
|
140
|
+
sudo screen -wipe > /dev/null
|
141
|
+
fi
|
142
|
+
CLEAN
|
143
|
+
end
|
144
|
+
|
145
|
+
def clean_up_previous_supervisor
|
146
|
+
return if config[:use_screen]
|
147
|
+
<<-EOH
|
148
|
+
[ -f ./run.pid ] && echo "Removing previous supervisor. "
|
149
|
+
[ -f ./run.pid ] && sudo kill $(cat run.pid)
|
150
|
+
[ -f ./run.pid ] && sleep 5
|
151
|
+
EOH
|
152
|
+
end
|
153
|
+
|
154
|
+
def run_package_in_background
|
155
|
+
if config[:use_screen]
|
156
|
+
"sudo screen -mdS \"#{clean_package_name}\" hab start #{package_ident} #{supervisor_options}"
|
157
|
+
else
|
158
|
+
<<-RUN
|
159
|
+
[ -f ./run.pid ] && rm -f run.pid
|
160
|
+
[ -f ./nohup.out ] && rm -f nohup.out
|
161
|
+
nohup sudo hab sup run #{sup_run_options} & echo $! > run.pid
|
162
|
+
|
163
|
+
until sudo hab svc status
|
164
|
+
do
|
165
|
+
sleep 1
|
166
|
+
done
|
167
|
+
|
168
|
+
sudo hab svc load #{package_ident} #{supervisor_options}
|
169
|
+
|
170
|
+
until sudo hab svc status | grep #{package_ident}
|
171
|
+
do
|
172
|
+
sleep 1
|
173
|
+
done
|
174
|
+
|
175
|
+
[ -f ./nohup.out ] && cat nohup.out || (echo "Failed to start the supervisor." && exit 1)
|
176
|
+
RUN
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def resolve_results_directory
|
181
|
+
return config[:results_directory] unless config[:results_directory].nil?
|
182
|
+
|
183
|
+
results_in_current = File.join(config[:kitchen_root], "results")
|
184
|
+
results_in_parent = File.join(config[:kitchen_root], "../results")
|
185
|
+
results_in_grandparent = File.join(config[:kitchen_root], "../../results")
|
186
|
+
|
187
|
+
if Dir.exist?(results_in_current)
|
188
|
+
results_in_current
|
189
|
+
elsif Dir.exist?(results_in_parent)
|
190
|
+
results_in_parent
|
191
|
+
elsif Dir.exist?(results_in_grandparent)
|
192
|
+
results_in_grandparent
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def copy_package_config_from_override_to_sandbox
|
197
|
+
return if config[:config_directory].nil?
|
198
|
+
return unless config[:override_package_config]
|
199
|
+
local_config_dir = File.join(config[:kitchen_root], config[:config_directory])
|
200
|
+
return unless Dir.exist?(local_config_dir)
|
201
|
+
|
202
|
+
sandbox_config_dir = File.join(sandbox_path, "config")
|
203
|
+
FileUtils.copy_entry(local_config_dir, sandbox_config_dir)
|
204
|
+
end
|
205
|
+
|
206
|
+
def copy_results_to_sandbox
|
207
|
+
return if config[:artifact_name].nil? && !config[:install_latest_artifact]
|
208
|
+
results_dir = resolve_results_directory
|
209
|
+
return if results_dir.nil?
|
210
|
+
FileUtils.mkdir_p(File.join(sandbox_path, "results"))
|
211
|
+
FileUtils.cp(
|
212
|
+
File.join(results_dir, config[:install_latest_artifact] ? latest_artifact_name : config[:artifact_name]),
|
213
|
+
File.join(sandbox_path, "results"),
|
214
|
+
preserve: true
|
215
|
+
)
|
216
|
+
end
|
217
|
+
|
218
|
+
def full_user_toml_path
|
219
|
+
File.join(File.join(config[:kitchen_root], config[:config_directory]), config[:user_toml_name])
|
220
|
+
end
|
221
|
+
|
222
|
+
def sandbox_user_toml_path
|
223
|
+
File.join(File.join(sandbox_path, "config"), "user.toml")
|
224
|
+
end
|
225
|
+
|
226
|
+
def copy_user_toml_to_sandbox
|
227
|
+
return if config[:config_directory].nil?
|
228
|
+
return unless File.exist?(full_user_toml_path)
|
229
|
+
FileUtils.mkdir_p(File.join(sandbox_path, "config"))
|
230
|
+
debug("Copying user.toml from #{full_user_toml_path} to #{sandbox_user_toml_path}")
|
231
|
+
FileUtils.cp(full_user_toml_path, sandbox_user_toml_path)
|
232
|
+
end
|
233
|
+
|
234
|
+
def install_service_package
|
235
|
+
return unless config[:install_latest_artifact] || !config[:artifact_name].nil?
|
236
|
+
|
237
|
+
artifact_name = ""
|
238
|
+
if config[:install_latest_artifact]
|
239
|
+
artifact_name = latest_artifact_name
|
240
|
+
elsif !config[:install_latest_artifact] && !config[:artifact_name].nil?
|
241
|
+
artifact_name = config[:artifact_name]
|
242
|
+
else
|
243
|
+
return
|
244
|
+
end
|
245
|
+
|
246
|
+
artifact_path = File.join(File.join(config[:root_path], "results"), artifact_name)
|
247
|
+
"sudo hab pkg install #{artifact_path}"
|
248
|
+
end
|
249
|
+
|
250
|
+
def latest_artifact_name
|
251
|
+
results_dir = resolve_results_directory
|
252
|
+
return if results_dir.nil?
|
253
|
+
|
254
|
+
artifact_path = Dir.glob(File.join(results_dir, "#{config[:package_origin]}-#{config[:package_name]}-*.hart")).max_by { |f| File.mtime(f) }
|
255
|
+
|
256
|
+
File.basename(artifact_path)
|
257
|
+
end
|
258
|
+
|
259
|
+
def copy_user_toml_to_service_directory
|
260
|
+
return unless !config[:config_directory].nil? && File.exist?(full_user_toml_path)
|
261
|
+
<<-EOH
|
262
|
+
sudo mkdir -p /hab/svc/#{config[:package_name]}
|
263
|
+
sudo cp #{File.join(File.join(config[:root_path], 'config'), 'user.toml')} /hab/svc/#{config[:package_name]}/user.toml
|
264
|
+
EOH
|
265
|
+
end
|
266
|
+
|
267
|
+
def remove_previous_user_toml
|
268
|
+
<<-REMOVE
|
269
|
+
if [ -d "/hab/svc/#{config[:package_name]}" ]; then
|
270
|
+
sudo find /hab/svc/#{config[:package_name]} -name user.toml -delete
|
271
|
+
fi
|
272
|
+
REMOVE
|
273
|
+
end
|
274
|
+
|
275
|
+
def export_hab_origin
|
276
|
+
return if config[:depot_url].nil?
|
277
|
+
"export HAB_ORIGIN=#{config[:depot_url]}"
|
278
|
+
end
|
279
|
+
|
280
|
+
def install_supervisor_command
|
281
|
+
"sudo hab pkg install #{hab_sup_ident}"
|
282
|
+
end
|
283
|
+
|
284
|
+
def binlink_supervisor_command
|
285
|
+
"sudo hab pkg binlink #{hab_sup_ident} hab-sup"
|
286
|
+
end
|
287
|
+
|
288
|
+
def artifact_name_to_package_ident_regex
|
289
|
+
/(?<origin>\w+)-(?<name>.*)-(?<version>(\d+)?(\.\d+)?(\.\d+)?(\.\d+)?)-(?<release>\d+)-(?<target>.*)\.hart$/
|
290
|
+
end
|
291
|
+
|
292
|
+
def hab_sup_ident
|
293
|
+
ident = "#{config[:hab_sup_origin]}/" \
|
294
|
+
"#{config[:hab_sup_name]}/" \
|
295
|
+
"#{config[:hab_sup_version]}/" \
|
296
|
+
"#{config[:hab_sup_release]}".chomp("/").chomp("/")
|
297
|
+
@sup_ident ||= ident
|
298
|
+
end
|
299
|
+
|
300
|
+
def package_ident
|
301
|
+
ident = "#{config[:package_origin]}/" \
|
302
|
+
"#{config[:package_name]}/" \
|
303
|
+
"#{config[:package_version]}/" \
|
304
|
+
"#{config[:package_release]}".chomp("/").chomp("/")
|
305
|
+
@pkg_ident ||= ident
|
306
|
+
end
|
307
|
+
|
308
|
+
def clean_package_name
|
309
|
+
@clean_name ||= "#{config[:package_origin]}-#{config[:package_name]}"
|
310
|
+
end
|
311
|
+
|
312
|
+
def sup_run_options
|
313
|
+
options = ''
|
314
|
+
options += " --listen-gossip #{config[:hab_sup_listen_gossip]}" unless config[:hab_sup_listen_gossip].nil?
|
315
|
+
options += " --config-from #{File.join(config[:root_path], 'config/')}" if config[:override_package_config]
|
316
|
+
options += config[:hab_sup_bind].map { |b| " --bind #{b}" }.join(" ") if config[:hab_sup_bind].any?
|
317
|
+
options += config[:hab_sup_peer].map { |p| " --peer #{p}" }.join(" ") if config[:hab_sup_peer].any?
|
318
|
+
|
319
|
+
options
|
320
|
+
end
|
321
|
+
|
322
|
+
def supervisor_options
|
323
|
+
options = ''
|
324
|
+
options += " --listen-gossip #{config[:hab_sup_listen_gossip]}" unless config[:hab_sup_listen_gossip].nil?
|
325
|
+
options += " --config-from #{File.join(config[:root_path], 'config/')}" if config[:override_package_config]
|
326
|
+
options += config[:hab_sup_bind].map { |b| " --bind #{b}" }.join(" ") if config[:hab_sup_bind].any?
|
327
|
+
# options += config[:hab_sup_peer].map { |p| " --peer #{p}" }.join(" ") if config[:hab_sup_peer].any?
|
328
|
+
options += " --group #{config[:hab_sup_group]}" unless config[:hab_sup_group].nil?
|
329
|
+
options += " --topology #{config[:service_topology]}" unless config[:service_topology].nil?
|
330
|
+
options += " --strategy #{config[:service_update_strategy]}" unless config[:service_update_strategy].nil?
|
331
|
+
options += " --channel #{config[:channel]}" unless config[:channel].nil?
|
332
|
+
|
333
|
+
options
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kitchen-habitat-config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steven Murawski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test-kitchen
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: countloc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: chefstyle
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: |+
|
98
|
+
== DESCRIPTION:
|
99
|
+
|
100
|
+
Habitat Provisioner for Test Kitchen
|
101
|
+
|
102
|
+
== FEATURES:
|
103
|
+
|
104
|
+
TBD
|
105
|
+
|
106
|
+
email:
|
107
|
+
- smurawski@chef.io
|
108
|
+
executables: []
|
109
|
+
extensions: []
|
110
|
+
extra_rdoc_files: []
|
111
|
+
files:
|
112
|
+
- README.md
|
113
|
+
- kitchen-habitat.gemspec
|
114
|
+
- lib/kitchen-habitat/version.rb
|
115
|
+
- lib/kitchen/provisioner/habitat.rb
|
116
|
+
homepage: https://github.com/test-kitchen/kitchen-habitat
|
117
|
+
licenses:
|
118
|
+
- Apache 2
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project: "[none]"
|
136
|
+
rubygems_version: 2.7.3
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Habitat provisioner for test-kitchen
|
140
|
+
test_files: []
|