kontena-plugin-vagrant 0.1.2 → 0.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDU5MzU3OGMzOGRiODNlNmExMzFlMDg2MmUwNjYzYWQxMzM1OGY1NQ==
4
+ YTc0YThjZGFlYmE5Y2VkOTdjZDlkMmUxNzhiMWUzMWIzNDliMWY1MQ==
5
5
  data.tar.gz: !binary |-
6
- ZDJhMzRiOWUzNTM0MWI4NzE5MDQ5NDE2ZDQ0MDM2N2FkZmIyNTk1Yg==
6
+ MGE2NmM1N2ZkMzkwOTk3MmUxMDk5ZGQxNDg3MmUyOTIzYzMyNjM0OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODZiYTFkOTZjZWI0OGJlM2IzYmQ2OWZhMmI0YzVhMzZhMmY0YmY1MDk4MThh
10
- M2RjZDhjZmQxZGEzMjZiN2QyZGFiMTNlNTJkOWRjZDNjODNhMDAwMWU5NGNh
11
- N2Y5OWI1OWQzNzJmYTgzMjU2YjJiNDc2ZGQwZWZkOWNiZGM1OTI=
9
+ ZDk3OTEwNWZkNzRiMGNiNDYxZDA4YmU5NDg4MmFhMmYyMzg1ODUxZTc1ZDNl
10
+ YzFjZmE4MTY0MzRlM2U1Zjc1ZGMwMDIzZWE2MDE5NmVkODJkMjAyMzExMzY0
11
+ ZDJiYzZiNTI2MWJmNjhiNjk3MzllMGFjZjNkZjZjZTc5ZTFjYzQ=
12
12
  data.tar.gz: !binary |-
13
- ZTIyMzQwZjBlMDI4MWMzMmEyZjc3NjUwMTU1MzZmMTJlZDI1NzdjNDcwZTI1
14
- MDJhM2Y1Mzk2MWQ3ZWQ0YThkYWIwODU5OGZlNDkzMmFiNTA1ZWMzOGY5ZjFi
15
- ZmI4MTI5MjFmZTg4MzkyNDkzMzhiNzVlNDI4YzNmMjkxMGIwOWM=
13
+ MzBjODY2NmJkZmI4NTViNmY5ZmRlOTIyOTZlN2VmZjMyMDgwNDI5ZTA3Y2M5
14
+ ZGFiZjhlNzVlYTViMDQxNjllZGQzZDE5MTZiZjYzM2JhMWU4ZmE3YTZiZGM3
15
+ OTgwMmQ3NzcyZDYwMzAyYjI1OGZhMGE5MmU4MzFlNzgyYjAwNGQ=
data/Gemfile CHANGED
@@ -4,8 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :development do
7
- gem "kontena-cli", "~> 0.15.0.rc1"
7
+ gem "kontena-cli", "~> 0.16.0.pre2"
8
8
  gem "listen", "~> 3.0.8"
9
- gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", tag: "v1.8.4"
10
9
  gem "rspec"
11
10
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_runtime_dependency 'kontena-cli', '>= 0.15.0.rc1'
20
+ spec.add_runtime_dependency 'kontena-cli', '>= 0.16.0.pre2'
21
21
  spec.add_development_dependency "bundler", "~> 1.11"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  end
@@ -69,7 +69,8 @@ coreos:
69
69
  --link kontena-server-mongo:mongodb \
70
70
  -e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
71
71
  -e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
72
- <% if auth_server %>-e AUTH_API_URL=<%= auth_server %><% end %> \
72
+ <% if server_name %>-e KONTENA_SERVER_NAME=<%= server_name %><% end %> \
73
+ <% if initial_admin_code %>-e KONTENA_INITIAL_ADMIN_CODE=<%= initial_admin_code %><% end %> \
73
74
  -p 8080:9292 \
74
75
  kontena/server:${KONTENA_VERSION}
75
76
  ExecStop=/usr/bin/docker stop kontena-server-api
@@ -5,6 +5,8 @@ module Kontena
5
5
  module Vagrant
6
6
  class MasterDestroyer
7
7
 
8
+ include Kontena::Cli::ShellSpinner
9
+
8
10
  attr_reader :client, :api_client
9
11
 
10
12
  # @param [Kontena::Client] api_client Kontena api client
@@ -15,7 +17,7 @@ module Kontena
15
17
  def run!
16
18
  vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
17
19
  Dir.chdir(vagrant_path) do
18
- ShellSpinner "Terminating Kontena Master from Vagrant " do
20
+ spinner "Terminating Kontena Master from Vagrant " do
19
21
  Open3.popen2('vagrant destroy -f') do |stdin, output, wait|
20
22
  while o = output.gets
21
23
  puts o if ENV['DEBUG']
@@ -1,7 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'erb'
3
3
  require 'open3'
4
- require 'shell-spinner'
5
4
 
6
5
  module Kontena
7
6
  module Machine
@@ -9,6 +8,7 @@ module Kontena
9
8
  class MasterProvisioner
10
9
  include RandomName
11
10
  include Kontena::Machine::Common
11
+ include Kontena::Cli::ShellSpinner
12
12
 
13
13
  API_URL = 'http://192.168.66.100:8080'
14
14
  attr_reader :client
@@ -21,9 +21,9 @@ module Kontena
21
21
  name = generate_name
22
22
  version = opts[:version]
23
23
  memory = opts[:memory] || 1024
24
- auth_server = opts[:auth_server]
25
24
  vault_secret = opts[:vault_secret]
26
25
  vault_iv = opts[:vault_iv]
26
+ initial_admin_code = opts[:initial_admin_code]
27
27
  vagrant_path = "#{Dir.home}/.kontena/vagrant_master/"
28
28
  if Dir.exist?(vagrant_path)
29
29
  puts "Oops... cannot create Kontena Master because installation path already exists."
@@ -36,10 +36,11 @@ module Kontena
36
36
  cloudinit_template = File.join(__dir__ , '/cloudinit.yml')
37
37
  vars = {
38
38
  name: name,
39
+ server_name: name.sub('kontena-master-', ''),
39
40
  version: version,
40
41
  memory: memory,
41
- auth_server: auth_server,
42
42
  vault_secret: vault_secret,
43
+ initial_admin_code: initial_admin_code,
43
44
  vault_iv: vault_iv,
44
45
  cloudinit: "#{vagrant_path}/cloudinit.yml"
45
46
  }
@@ -48,19 +49,28 @@ module Kontena
48
49
  File.write("#{vagrant_path}/Vagrantfile", vagrant_data)
49
50
  File.write("#{vagrant_path}/cloudinit.yml", cloudinit)
50
51
  Dir.chdir(vagrant_path) do
51
- ShellSpinner "Creating Vagrant machine #{name.colorize(:cyan)} " do
52
+ spinner "Creating Vagrant machine #{name.colorize(:cyan)} " do
52
53
  Open3.popen2("vagrant up") do |stdin, output, wait|
53
54
  while o = output.gets
54
55
  print o if ENV['DEBUG']
55
56
  end
56
57
  end
57
58
  end
58
- ShellSpinner "Waiting for #{name.colorize(:cyan)} to start " do
59
- sleep 1 until master_running?
60
- end
61
- puts "Kontena Master is now running at #{API_URL}"
62
- puts "Use #{"kontena login --name #{name.sub('kontena-master-', '')} #{API_URL}".colorize(:light_black)} to complete Kontena Master setup"
63
59
  end
60
+
61
+ spinner "Waiting for #{name.colorize(:cyan)} to start " do
62
+ sleep 1 until master_running?
63
+ end
64
+
65
+ puts
66
+ puts "Kontena Master is now running at #{API_URL}".colorize(:green)
67
+ puts
68
+
69
+ {
70
+ name: name.sub('kontena-master-', ''),
71
+ public_ip: API_URL.split('//').last,
72
+ code: opts[:initial_admin_code]
73
+ }
64
74
  end
65
75
 
66
76
  def erb(template, vars)
@@ -5,6 +5,7 @@ module Kontena
5
5
  module Vagrant
6
6
  class NodeDestroyer
7
7
  include RandomName
8
+ include Kontena::Cli::ShellSpinner
8
9
 
9
10
  attr_reader :client, :api_client
10
11
 
@@ -16,7 +17,7 @@ module Kontena
16
17
  def run!(grid, name)
17
18
  vagrant_path = "#{Dir.home}/.kontena/#{grid}/#{name}"
18
19
  Dir.chdir(vagrant_path) do
19
- ShellSpinner "Terminating Vagrant machine #{name.colorize(:cyan)} " do
20
+ spinner "Terminating Vagrant machine #{name.colorize(:cyan)} " do
20
21
  Open3.popen2('vagrant destroy -f') do |stdin, output, wait|
21
22
  while o = output.gets
22
23
  puts o if ENV['DEBUG']
@@ -29,7 +30,7 @@ module Kontena
29
30
  end
30
31
  node = api_client.get("grids/#{grid}/nodes")['nodes'].find{|n| n['name'] == name}
31
32
  if node
32
- ShellSpinner "Removing node #{name.colorize(:cyan)} from grid #{grid.colorize(:cyan)} " do
33
+ spinner "Removing node #{name.colorize(:cyan)} from grid #{grid.colorize(:cyan)} " do
33
34
  api_client.delete("grids/#{grid}/nodes/#{name}")
34
35
  end
35
36
  end
@@ -1,13 +1,13 @@
1
1
  require 'fileutils'
2
2
  require 'erb'
3
3
  require 'open3'
4
- require 'shell-spinner'
5
4
 
6
5
  module Kontena
7
6
  module Machine
8
7
  module Vagrant
9
8
  class NodeProvisioner
10
9
  include RandomName
10
+ include Kontena::Cli::ShellSpinner
11
11
 
12
12
  attr_reader :client, :api_client
13
13
 
@@ -43,15 +43,15 @@ module Kontena
43
43
  File.write("#{vagrant_path}/cloudinit.yml", cloudinit)
44
44
  node = nil
45
45
  Dir.chdir(vagrant_path) do
46
- ShellSpinner "Creating Vagrant machine #{name.colorize(:cyan)} " do
46
+ spinner "Creating Vagrant machine #{name.colorize(:cyan)} " do
47
47
  Open3.popen2('vagrant up') do |stdin, output, wait|
48
48
  while o = output.gets
49
49
  print o if ENV['DEBUG']
50
50
  end
51
51
  end
52
52
  end
53
- ShellSpinner "Waiting for node #{name.colorize(:cyan)} join to grid #{grid.colorize(:cyan)} " do
54
- sleep 1 until node = node_exists_in_grid?(grid, name)
53
+ spinner "Waiting for node #{name.colorize(:cyan)} join to grid #{grid.colorize(:cyan)} " do
54
+ sleep 1 until node_exists_in_grid?(grid, name)
55
55
  end
56
56
  end
57
57
  set_labels(
@@ -5,18 +5,18 @@ module Kontena::Plugin::Vagrant::Master
5
5
 
6
6
  option "--memory", "MEMORY", "How much memory node has", default: '512'
7
7
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
8
- option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
9
8
  option "--vault-secret", "VAULT_SECRET", "Secret key for Vault"
10
9
  option "--vault-iv", "VAULT_IV", "Initialization vector for Vault"
10
+ option "--name", "NAME", "Set Master name"
11
11
 
12
12
  def execute
13
13
  require_relative '../../../machine/vagrant'
14
14
  provisioner.run!(
15
15
  memory: memory,
16
16
  version: version,
17
- auth_server: auth_provider_url,
18
17
  vault_secret: vault_secret || SecureRandom.hex(24),
19
- vault_iv: vault_iv || SecureRandom.hex(24)
18
+ vault_iv: vault_iv || SecureRandom.hex(24),
19
+ initial_admin_code: SecureRandom.hex(16)
20
20
  )
21
21
  end
22
22
 
@@ -1,6 +1,7 @@
1
1
  module Kontena::Plugin::Vagrant::Master
2
2
  class RestartCommand < Kontena::Command
3
3
  include Kontena::Cli::Common
4
+ include Kontena::Cli::ShellSpinner
4
5
 
5
6
  def execute
6
7
  require_relative '../../../machine/vagrant'
@@ -8,7 +9,7 @@ module Kontena::Plugin::Vagrant::Master
8
9
  vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
9
10
  abort("Cannot find Vagrant kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
10
11
  Dir.chdir(vagrant_path) do
11
- ShellSpinner "Restarting Vagrant kontena-master " do
12
+ spinner "Restarting Vagrant kontena-master " do
12
13
  Open3.popen2('vagrant reload') do |stdin, output, wait|
13
14
  while o = output.gets
14
15
  print o if ENV['DEBUG']
@@ -1,6 +1,7 @@
1
1
  module Kontena::Plugin::Vagrant::Master
2
2
  class StartCommand < Kontena::Command
3
3
  include Kontena::Cli::Common
4
+ include Kontena::Cli::ShellSpinner
4
5
 
5
6
  def execute
6
7
  require_relative '../../../machine/vagrant'
@@ -8,7 +9,7 @@ module Kontena::Plugin::Vagrant::Master
8
9
  vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
9
10
  abort("Cannot find Vagrant node kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
10
11
  Dir.chdir(vagrant_path) do
11
- ShellSpinner "Starting Vagrant machine kontena-master " do
12
+ spinner "Starting Vagrant machine kontena-master " do
12
13
  Open3.popen2('vagrant up') do |stdin, output, wait|
13
14
  while o = output.gets
14
15
  print o if ENV['DEBUG']
@@ -1,6 +1,7 @@
1
1
  module Kontena::Plugin::Vagrant::Master
2
2
  class StopCommand < Kontena::Command
3
3
  include Kontena::Cli::Common
4
+ include Kontena::Cli::ShellSpinner
4
5
 
5
6
  def execute
6
7
  require_relative '../../../machine/vagrant'
@@ -8,7 +9,7 @@ module Kontena::Plugin::Vagrant::Master
8
9
  vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
9
10
  abort("Cannot find Vagrant kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
10
11
  Dir.chdir(vagrant_path) do
11
- ShellSpinner "Stopping Vagrant kontena-master " do
12
+ spinner "Stopping Vagrant kontena-master " do
12
13
  Open3.popen2('vagrant halt') do |stdin, output, wait|
13
14
  while o = output.gets
14
15
  print o if ENV['DEBUG']
@@ -2,6 +2,7 @@ module Kontena::Plugin::Vagrant::Nodes
2
2
  class RestartCommand < Kontena::Command
3
3
  include Kontena::Cli::Common
4
4
  include Kontena::Cli::GridOptions
5
+ include Kontena::Cli::ShellSpinner
5
6
 
6
7
  parameter "NAME", "Node name"
7
8
 
@@ -10,12 +11,11 @@ module Kontena::Plugin::Vagrant::Nodes
10
11
  require_current_grid
11
12
 
12
13
  require_relative '../../../machine/vagrant'
13
- require 'shell-spinner'
14
14
 
15
15
  vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
16
16
  abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
17
17
  Dir.chdir(vagrant_path) do
18
- ShellSpinner "Restarting Vagrant machine #{name.colorize(:cyan)} " do
18
+ spinner "Restarting Vagrant machine #{name.colorize(:cyan)} " do
19
19
  Open3.popen2('vagrant reload') do |stdin, output, wait|
20
20
  while o = output.gets
21
21
  print o if ENV['DEBUG']
@@ -2,6 +2,7 @@ module Kontena::Plugin::Vagrant::Nodes
2
2
  class StartCommand < Kontena::Command
3
3
  include Kontena::Cli::Common
4
4
  include Kontena::Cli::GridOptions
5
+ include Kontena::Cli::ShellSpinner
5
6
 
6
7
  parameter "NAME", "Node name"
7
8
 
@@ -14,7 +15,7 @@ module Kontena::Plugin::Vagrant::Nodes
14
15
  vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
15
16
  abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
16
17
  Dir.chdir(vagrant_path) do
17
- ShellSpinner "Starting Vagrant machine #{name.colorize(:cyan)} " do
18
+ spinner "Starting Vagrant machine #{name.colorize(:cyan)} " do
18
19
  Open3.popen2('vagrant up') do |stdin, output, wait|
19
20
  while o = output.gets
20
21
  print o if ENV['DEBUG']
@@ -2,6 +2,7 @@ module Kontena::Plugin::Vagrant::Nodes
2
2
  class StopCommand < Clamp::Command
3
3
  include Kontena::Cli::Common
4
4
  include Kontena::Cli::GridOptions
5
+ include Kontena::Cli::ShellSpinner
5
6
 
6
7
  parameter "NAME", "Node name"
7
8
 
@@ -14,7 +15,7 @@ module Kontena::Plugin::Vagrant::Nodes
14
15
  vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
15
16
  abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
16
17
  Dir.chdir(vagrant_path) do
17
- ShellSpinner "Stopping Vagrant machine #{name.colorize(:cyan)} " do
18
+ spinner "Stopping Vagrant machine #{name.colorize(:cyan)} " do
18
19
  Open3.popen2('vagrant halt') do |stdin, output, wait|
19
20
  while o = output.gets
20
21
  print o if ENV['DEBUG']
@@ -1,7 +1,7 @@
1
1
  module Kontena
2
2
  module Plugin
3
3
  module Vagrant
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0.pre1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-plugin-vagrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kontena-cli
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.15.0.rc1
19
+ version: 0.16.0.pre2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.15.0.rc1
26
+ version: 0.16.0.pre2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -109,9 +109,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - ! '>='
112
+ - - ! '>'
113
113
  - !ruby/object:Gem::Version
114
- version: '0'
114
+ version: 1.3.1
115
115
  requirements: []
116
116
  rubyforge_project:
117
117
  rubygems_version: 2.4.5