kontena-plugin-vagrant 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.ruby-gemset +1 -0
  6. data/Gemfile +10 -0
  7. data/LICENSE.txt +191 -0
  8. data/README.md +75 -0
  9. data/kontena-plugin-vagrant.gemspec +23 -0
  10. data/lib/kontena/machine/vagrant.rb +12 -0
  11. data/lib/kontena/machine/vagrant/Vagrantfile.master.rb.erb +105 -0
  12. data/lib/kontena/machine/vagrant/Vagrantfile.node.rb.erb +33 -0
  13. data/lib/kontena/machine/vagrant/cloudinit.yml +74 -0
  14. data/lib/kontena/machine/vagrant/master_destroyer.rb +33 -0
  15. data/lib/kontena/machine/vagrant/master_provisioner.rb +82 -0
  16. data/lib/kontena/machine/vagrant/node_destroyer.rb +40 -0
  17. data/lib/kontena/machine/vagrant/node_provisioner.rb +72 -0
  18. data/lib/kontena/plugin/vagrant.rb +7 -0
  19. data/lib/kontena/plugin/vagrant/master/create_command.rb +27 -0
  20. data/lib/kontena/plugin/vagrant/master/restart_command.rb +21 -0
  21. data/lib/kontena/plugin/vagrant/master/ssh_command.rb +16 -0
  22. data/lib/kontena/plugin/vagrant/master/start_command.rb +21 -0
  23. data/lib/kontena/plugin/vagrant/master/stop_command.rb +21 -0
  24. data/lib/kontena/plugin/vagrant/master/terminate_command.rb +21 -0
  25. data/lib/kontena/plugin/vagrant/master_command.rb +19 -0
  26. data/lib/kontena/plugin/vagrant/node_command.rb +19 -0
  27. data/lib/kontena/plugin/vagrant/nodes/create_command.rb +42 -0
  28. data/lib/kontena/plugin/vagrant/nodes/restart_command.rb +28 -0
  29. data/lib/kontena/plugin/vagrant/nodes/ssh_command.rb +22 -0
  30. data/lib/kontena/plugin/vagrant/nodes/start_command.rb +27 -0
  31. data/lib/kontena/plugin/vagrant/nodes/stop_command.rb +27 -0
  32. data/lib/kontena/plugin/vagrant/nodes/terminate_command.rb +26 -0
  33. data/lib/kontena/plugin/vagrant_command.rb +11 -0
  34. data/lib/kontena_cli_plugin.rb +5 -0
  35. metadata +119 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 272dccfc1e26cce40e38263486f90b6ee3036523
4
+ data.tar.gz: 642210872b3a1ae9e7f91578358581167c8c73ae
5
+ SHA512:
6
+ metadata.gz: 71c10f52918f7eaced23ad8ec43c977f90fbaccf75af6824ceb2d041a2aed2c36ce8384753e9e42789e7d694d2ae2acec70e1c3466151eebcc57288c5f176f9e
7
+ data.tar.gz: cdd6c447c83e5f0fe133c2717a46140d0d96da3781029b49cef10d13edeabc51410c94d5207a0cdeff3635a38bb9b24a238a6eabfbc847552ef2826315079031
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "kontena"]
2
+ path = kontena
3
+ url = https://github.com/kontena/kontena.git
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ kontena-plugin-vagrant
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kontena-plugin-aws.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "kontena-cli", path: "./kontena/cli"
8
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
9
+ gem 'rspec'
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2015 Kontena, Inc.
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Kontena Vagrant Plugin
2
+
3
+ This plugin provides support for Vagrant provisioning to Kontena CLI. Easiest way to test full Kontena Platform setup locally.
4
+
5
+ ## System Requirements
6
+
7
+ - [Kontena CLI](https://kontena.io/)
8
+ - [Vagrant](https://www.vagrantup.com/)
9
+ - [VirtualBox](https://www.virtualbox.org/)
10
+
11
+ ## Installation
12
+
13
+ ```
14
+ $ kontena plugin install vagrant
15
+ ```
16
+
17
+ ## Commands
18
+
19
+ #### Vagrant Master
20
+
21
+ ```
22
+ $ kontena vagrant master
23
+ Usage:
24
+ kontena vagrant master [OPTIONS] SUBCOMMAND [ARG] ...
25
+
26
+ Parameters:
27
+ SUBCOMMAND subcommand
28
+ [ARG] ... subcommand arguments
29
+
30
+ Subcommands:
31
+ create Create a new Vagrant master
32
+ ssh SSH into Vagrant master
33
+ start Start Vagrant master
34
+ stop Stop Vagrant master
35
+ restart Restart Vagrant master
36
+ terminate Terminate Vagrant master
37
+
38
+ Options:
39
+ -h, --help print help
40
+ ```
41
+
42
+ #### Vagrant Node
43
+
44
+ ```
45
+ $ kontena vagrant node
46
+ Usage:
47
+ kontena vagrant node [OPTIONS] SUBCOMMAND [ARG] ...
48
+
49
+ Parameters:
50
+ SUBCOMMAND subcommand
51
+ [ARG] ... subcommand arguments
52
+
53
+ Subcommands:
54
+ create Create a new node to Vagrant
55
+ ssh Ssh into Vagrant node
56
+ start Start Vagrant node
57
+ stop Stop Vagrant node
58
+ restart Restart Vagrant node
59
+ terminate Terminate Vagrant node
60
+
61
+ Options:
62
+ -h, --help print help
63
+ ```
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it ( https://github.com/kontena/kontena-plugin-vagrant )
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create a new Pull Request
72
+
73
+ ## License
74
+
75
+ Kontena is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE.txt) for full license text.
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kontena/plugin/vagrant'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kontena-plugin-vagrant"
8
+ spec.version = Kontena::Plugin::Vagrant::VERSION
9
+ spec.authors = ["Kontena, Inc."]
10
+ spec.email = ["info@kontena.io"]
11
+
12
+ spec.summary = "Kontena Vagrant plugin"
13
+ spec.description = "Kontena Vagrant plugin"
14
+ spec.homepage = "https://github.com/kontena/kontena-plugin-vagrant"
15
+ spec.license = "Apache-2.0"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency 'kontena-cli', '>= 0.15.0.rc1'
21
+ spec.add_development_dependency "bundler", "~> 1.11"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,12 @@
1
+ require 'kontena/machine/common'
2
+ include Kontena::Machine::Common
3
+
4
+ unless which('vagrant')
5
+ abort('Vagrant is not installed. See https://www.vagrantup.com/ for instructions.')
6
+ end
7
+
8
+ require 'kontena/machine/random_name'
9
+ require_relative 'vagrant/master_provisioner'
10
+ require_relative 'vagrant/master_destroyer'
11
+ require_relative 'vagrant/node_provisioner'
12
+ require_relative 'vagrant/node_destroyer'
@@ -0,0 +1,105 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ cloud_init = <<INIT
8
+ #cloud-config
9
+ write_files:
10
+ - path: /etc/kontena-server.env
11
+ permissions: 0600
12
+ owner: root
13
+ content: |
14
+ KONTENA_VERSION=<%= version %>
15
+ KONTENA_VAULT_KEY=<%= vault_secret %>
16
+ KONTENA_VAULT_IV=<%= vault_iv %>
17
+ coreos:
18
+ update:
19
+ reboot-strategy: off
20
+ units:
21
+ - name: kontena-server-mongo.service
22
+ command: start
23
+ enable: true
24
+ content: |
25
+ [Unit]
26
+ Description=kontena-server-mongo
27
+ After=network-online.target
28
+ After=docker.service
29
+ Description=Kontena Server MongoDB
30
+ Documentation=http://www.mongodb.org/
31
+ Requires=network-online.target
32
+ Requires=docker.service
33
+
34
+ [Service]
35
+ Restart=always
36
+ RestartSec=5
37
+ ExecStartPre=/usr/bin/docker pull mongo:3.0
38
+ ExecStartPre=-/usr/bin/docker create --name=kontena-server-mongo-data mongo:3.0
39
+ ExecStartPre=-/usr/bin/docker stop kontena-server-mongo
40
+ ExecStartPre=-/usr/bin/docker rm kontena-server-mongo
41
+ ExecStart=/usr/bin/docker run --name=kontena-server-mongo \
42
+ --volumes-from=kontena-server-mongo-data \
43
+ mongo:3.0 mongod --smallfiles
44
+
45
+ - name: kontena-server-api.service
46
+ command: start
47
+ enable: true
48
+ content: |
49
+ [Unit]
50
+ Description=kontena-server-api
51
+ After=network-online.target
52
+ After=docker.service
53
+ After=kontena-server-mongo.service
54
+ Description=Kontena Master
55
+ Documentation=http://www.kontena.io/
56
+ Requires=network-online.target
57
+ Requires=docker.service
58
+ Requires=kontena-server-mongo.service
59
+
60
+ [Service]
61
+ Restart=always
62
+ RestartSec=5
63
+ EnvironmentFile=/etc/kontena-server.env
64
+ ExecStartPre=-/usr/bin/docker stop kontena-server-api
65
+ ExecStartPre=-/usr/bin/docker rm kontena-server-api
66
+ ExecStartPre=/usr/bin/docker pull kontena/server:${KONTENA_VERSION}
67
+ ExecStart=/usr/bin/docker run --name kontena-server-api \
68
+ --link kontena-server-mongo:mongodb \
69
+ -e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
70
+ -e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
71
+ <% if auth_server %>-e AUTH_API_URL=<%= auth_server %><% end %> \
72
+ -p 8080:9292 \
73
+ kontena/server:${KONTENA_VERSION}
74
+ INIT
75
+
76
+ cloud_init_file = Tempfile.new('kontena-master')
77
+ File.write(cloud_init_file.path, cloud_init)
78
+
79
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
80
+ config.vm.provider :virtualbox do |v|
81
+ v.check_guest_additions = false
82
+ v.functional_vboxsf = false
83
+ end
84
+
85
+ if Vagrant.has_plugin?("vagrant-vbguest") then
86
+ config.vbguest.auto_update = false
87
+ end
88
+
89
+ config.vm.define "<%= name %>" do |docker|
90
+ docker.vm.box = "coreos-stable"
91
+ docker.vm.box_url = "http://stable.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json"
92
+ docker.vm.network "private_network", ip: "192.168.66.100"
93
+ docker.vm.hostname = "<%= name %>"
94
+ docker.vm.provider "virtualbox" do |vb|
95
+ vb.name = "<%= name %>"
96
+ vb.gui = false
97
+ vb.customize ["modifyvm", :id, "--memory", "512"]
98
+ vb.auto_nat_dns_proxy = false
99
+ vb.customize ["modifyvm", :id, "--natdnsproxy1", "off" ]
100
+ vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off" ]
101
+ end
102
+ docker.vm.provision :file, :source => cloud_init_file.path, :destination => "/tmp/vagrantfile-user-data"
103
+ docker.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
104
+ end
105
+ end
@@ -0,0 +1,33 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
+ config.vm.provider :virtualbox do |v|
9
+ v.check_guest_additions = false
10
+ v.functional_vboxsf = false
11
+ end
12
+
13
+ if Vagrant.has_plugin?("vagrant-vbguest") then
14
+ config.vbguest.auto_update = false
15
+ end
16
+
17
+ config.vm.define "<%= name %>" do |docker|
18
+ docker.vm.box = "coreos-stable"
19
+ docker.vm.box_url = "http://stable.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json"
20
+ docker.vm.network "private_network", type: "dhcp"
21
+ docker.vm.hostname = "<%= name %>"
22
+ docker.vm.provider "virtualbox" do |vb|
23
+ vb.name = "<%= name %>"
24
+ vb.gui = false
25
+ vb.customize ["modifyvm", :id, "--memory", "<%= memory %>"]
26
+ vb.auto_nat_dns_proxy = false
27
+ vb.customize ["modifyvm", :id, "--natdnsproxy1", "off" ]
28
+ vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off" ]
29
+ end
30
+ docker.vm.provision :file, :source => "<%= cloudinit %>", :destination => "/tmp/vagrantfile-user-data"
31
+ docker.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
32
+ end
33
+ end
@@ -0,0 +1,74 @@
1
+ #cloud-config
2
+ write_files:
3
+ - path: /etc/kontena-agent.env
4
+ permissions: 0600
5
+ owner: root
6
+ content: |
7
+ KONTENA_URI="<%= master_uri %>"
8
+ KONTENA_TOKEN="<%= grid_token %>"
9
+ KONTENA_PEER_INTERFACE=eth1
10
+ KONTENA_VERSION=<%= version %>
11
+ - path: /etc/systemd/system/docker.service.d/50-kontena.conf
12
+ content: |
13
+ [Service]
14
+ Environment='DOCKER_OPTS=--insecure-registry="10.81.0.0/19" --bip="172.17.43.1/16"'
15
+ Environment='DOCKER_CGROUPS=--exec-opt native.cgroupdriver=cgroupfs'
16
+ - path: /etc/sysctl.d/99-inotify.conf
17
+ owner: root
18
+ permissions: 0644
19
+ content: |
20
+ fs.inotify.max_user_instances = 8192
21
+ coreos:
22
+ update:
23
+ reboot-strategy: off
24
+ units:
25
+ - name: 00-eth.network
26
+ runtime: true
27
+ content: |
28
+ [Match]
29
+ Name=eth*
30
+ [Network]
31
+ DHCP=yes
32
+ DNS=172.17.43.1
33
+ DNS=172.28.128.1
34
+ DNS=8.8.8.8
35
+ DOMAINS=kontena.local
36
+ [DHCP]
37
+ UseDNS=false
38
+
39
+ - name: 10-weave.network
40
+ runtime: false
41
+ content: |
42
+ [Match]
43
+ Type=bridge
44
+ Name=weave*
45
+
46
+ [Network]
47
+ - name: kontena-agent.service
48
+ command: start
49
+ enable: true
50
+ content: |
51
+ [Unit]
52
+ Description=kontena-agent
53
+ After=network-online.target
54
+ After=docker.service
55
+ Description=Kontena Agent
56
+ Documentation=http://www.kontena.io/
57
+ Requires=network-online.target
58
+ Requires=docker.service
59
+
60
+ [Service]
61
+ Restart=always
62
+ RestartSec=5
63
+ EnvironmentFile=/etc/kontena-agent.env
64
+ ExecStartPre=-/usr/bin/docker stop kontena-agent
65
+ ExecStartPre=-/usr/bin/docker rm kontena-agent
66
+ ExecStartPre=/usr/bin/docker pull kontena/agent:${KONTENA_VERSION}
67
+ ExecStart=/usr/bin/docker run --name kontena-agent \
68
+ -e KONTENA_URI=${KONTENA_URI} \
69
+ -e KONTENA_TOKEN=${KONTENA_TOKEN} \
70
+ -e KONTENA_PEER_INTERFACE=${KONTENA_PEER_INTERFACE} \
71
+ -v=/var/run/docker.sock:/var/run/docker.sock \
72
+ -v=/etc/kontena-agent.env:/etc/kontena.env \
73
+ --net=host \
74
+ kontena/agent:${KONTENA_VERSION}
@@ -0,0 +1,33 @@
1
+ require 'fileutils'
2
+
3
+ module Kontena
4
+ module Machine
5
+ module Vagrant
6
+ class MasterDestroyer
7
+
8
+ attr_reader :client, :api_client
9
+
10
+ # @param [Kontena::Client] api_client Kontena api client
11
+ def initialize(api_client)
12
+ @api_client = api_client
13
+ end
14
+
15
+ def run!
16
+ vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
17
+ Dir.chdir(vagrant_path) do
18
+ ShellSpinner "Terminating Kontena Master from Vagrant " do
19
+ Open3.popen2('vagrant destroy -f') do |stdin, output, wait|
20
+ while o = output.gets
21
+ puts o if ENV['DEBUG']
22
+ end
23
+ if wait.value == 0
24
+ FileUtils.remove_entry_secure(vagrant_path)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,82 @@
1
+ require 'fileutils'
2
+ require 'erb'
3
+ require 'open3'
4
+ require 'shell-spinner'
5
+
6
+ module Kontena
7
+ module Machine
8
+ module Vagrant
9
+ class MasterProvisioner
10
+ include RandomName
11
+ include Kontena::Machine::Common
12
+
13
+ API_URL = 'http://192.168.66.100:8080'
14
+ attr_reader :client
15
+
16
+ def initialize
17
+ @client = Excon.new(API_URL)
18
+ end
19
+
20
+ def run!(opts)
21
+ name = generate_name
22
+ version = opts[:version]
23
+ memory = opts[:memory] || 1024
24
+ auth_server = opts[:auth_server]
25
+ vault_secret = opts[:vault_secret]
26
+ vault_iv = opts[:vault_iv]
27
+ vagrant_path = "#{Dir.home}/.kontena/vagrant_master/"
28
+ if Dir.exist?(vagrant_path)
29
+ puts "Oops... cannot create Kontena Master because installation path already exists."
30
+ puts "If you are sure that no Kontena Masters exist on this machine, remove folder: #{vagrant_path}"
31
+ abort
32
+ end
33
+ FileUtils.mkdir_p(vagrant_path)
34
+
35
+ template = File.join(__dir__ , '/Vagrantfile.master.rb.erb')
36
+ cloudinit_template = File.join(__dir__ , '/cloudinit.yml')
37
+ vars = {
38
+ name: name,
39
+ version: version,
40
+ memory: memory,
41
+ auth_server: auth_server,
42
+ vault_secret: vault_secret,
43
+ vault_iv: vault_iv,
44
+ cloudinit: "#{vagrant_path}/cloudinit.yml"
45
+ }
46
+ vagrant_data = erb(File.read(template), vars)
47
+ cloudinit = erb(File.read(cloudinit_template), vars)
48
+ File.write("#{vagrant_path}/Vagrantfile", vagrant_data)
49
+ File.write("#{vagrant_path}/cloudinit.yml", cloudinit)
50
+ Dir.chdir(vagrant_path) do
51
+ ShellSpinner "Creating Vagrant machine #{name.colorize(:cyan)} " do
52
+ Open3.popen2("vagrant up") do |stdin, output, wait|
53
+ while o = output.gets
54
+ print o if ENV['DEBUG']
55
+ end
56
+ end
57
+ 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
+ end
64
+ end
65
+
66
+ def erb(template, vars)
67
+ ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
68
+ end
69
+
70
+ def master_running?
71
+ client.get(path: '/').status == 200
72
+ rescue
73
+ false
74
+ end
75
+
76
+ def generate_name
77
+ "kontena-master-#{super}-#{rand(1..99)}"
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,40 @@
1
+ require 'fileutils'
2
+
3
+ module Kontena
4
+ module Machine
5
+ module Vagrant
6
+ class NodeDestroyer
7
+ include RandomName
8
+
9
+ attr_reader :client, :api_client
10
+
11
+ # @param [Kontena::Client] api_client Kontena api client
12
+ def initialize(api_client)
13
+ @api_client = api_client
14
+ end
15
+
16
+ def run!(grid, name)
17
+ vagrant_path = "#{Dir.home}/.kontena/#{grid}/#{name}"
18
+ Dir.chdir(vagrant_path) do
19
+ ShellSpinner "Terminating Vagrant machine #{name.colorize(:cyan)} " do
20
+ Open3.popen2('vagrant destroy -f') do |stdin, output, wait|
21
+ while o = output.gets
22
+ puts o if ENV['DEBUG']
23
+ end
24
+ if wait.value == 0
25
+ FileUtils.remove_entry_secure(vagrant_path)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ node = api_client.get("grids/#{grid}/nodes")['nodes'].find{|n| n['name'] == name}
31
+ if node
32
+ ShellSpinner "Removing node #{name.colorize(:cyan)} from grid #{grid.colorize(:cyan)} " do
33
+ api_client.delete("grids/#{grid}/nodes/#{name}")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,72 @@
1
+ require 'fileutils'
2
+ require 'erb'
3
+ require 'open3'
4
+ require 'shell-spinner'
5
+
6
+ module Kontena
7
+ module Machine
8
+ module Vagrant
9
+ class NodeProvisioner
10
+ include RandomName
11
+
12
+ attr_reader :client, :api_client
13
+
14
+ # @param [Kontena::Client] api_client Kontena api client
15
+ def initialize(api_client)
16
+ @api_client = api_client
17
+ end
18
+
19
+ def run!(opts)
20
+ grid = opts[:grid]
21
+ if opts[:name]
22
+ name = "#{opts[:name]}-#{opts[:instance_number]}"
23
+ else
24
+ name = generate_name
25
+ end
26
+ version = opts[:version]
27
+ vagrant_path = "#{Dir.home}/.kontena/#{grid}/#{name}"
28
+ FileUtils.mkdir_p(vagrant_path)
29
+
30
+ template = File.join(__dir__ , '/Vagrantfile.node.rb.erb')
31
+ cloudinit_template = File.join(__dir__ , '/cloudinit.yml')
32
+ vars = {
33
+ name: name,
34
+ version: version,
35
+ memory: opts[:memory] || 1024,
36
+ master_uri: opts[:master_uri],
37
+ grid_token: opts[:grid_token],
38
+ cloudinit: "#{vagrant_path}/cloudinit.yml"
39
+ }
40
+ vagrant_data = erb(File.read(template), vars)
41
+ cloudinit = erb(File.read(cloudinit_template), vars)
42
+ File.write("#{vagrant_path}/Vagrantfile", vagrant_data)
43
+ File.write("#{vagrant_path}/cloudinit.yml", cloudinit)
44
+ Dir.chdir(vagrant_path) do
45
+ ShellSpinner "Creating Vagrant machine #{name.colorize(:cyan)} " do
46
+ Open3.popen2('vagrant up') do |stdin, output, wait|
47
+ while o = output.gets
48
+ print o if ENV['DEBUG']
49
+ end
50
+ end
51
+ end
52
+ ShellSpinner "Waiting for node #{name.colorize(:cyan)} join to grid #{grid.colorize(:cyan)} " do
53
+ sleep 1 until node_exists_in_grid?(grid, name)
54
+ end
55
+ end
56
+ end
57
+
58
+ def generate_name
59
+ "#{super}-#{rand(1..99)}"
60
+ end
61
+
62
+ def erb(template, vars)
63
+ ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
64
+ end
65
+
66
+ def node_exists_in_grid?(grid, name)
67
+ api_client.get("grids/#{grid}/nodes")['nodes'].find{|n| n['name'] == name}
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,7 @@
1
+ module Kontena
2
+ module Plugin
3
+ module Vagrant
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ require 'securerandom'
2
+
3
+ module Kontena::Plugin::Vagrant::Master
4
+ class CreateCommand < Kontena::Command
5
+
6
+ option "--memory", "MEMORY", "How much memory node has", default: '512'
7
+ option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
8
+ option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
9
+ option "--vault-secret", "VAULT_SECRET", "Secret key for Vault"
10
+ option "--vault-iv", "VAULT_IV", "Initialization vector for Vault"
11
+
12
+ def execute
13
+ require_relative '../../../machine/vagrant'
14
+ provisioner.run!(
15
+ memory: memory,
16
+ version: version,
17
+ auth_server: auth_provider_url,
18
+ vault_secret: vault_secret || SecureRandom.hex(24),
19
+ vault_iv: vault_iv || SecureRandom.hex(24)
20
+ )
21
+ end
22
+
23
+ def provisioner
24
+ Kontena::Machine::Vagrant::MasterProvisioner.new
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ module Kontena::Plugin::Vagrant::Master
2
+ class RestartCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+
5
+ def execute
6
+ require_relative '../../../machine/vagrant'
7
+
8
+ vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
9
+ abort("Cannot find Vagrant kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
10
+ Dir.chdir(vagrant_path) do
11
+ ShellSpinner "Restarting Vagrant kontena-master " do
12
+ Open3.popen2('vagrant reload') do |stdin, output, wait|
13
+ while o = output.gets
14
+ print o if ENV['DEBUG']
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ module Kontena::Plugin::Vagrant::Master
2
+ class SshCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+
5
+ def execute
6
+ require_relative '../../../machine/vagrant'
7
+
8
+ vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
9
+ abort("Cannot find Vagrant kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
10
+
11
+ Dir.chdir(vagrant_path) do
12
+ system('vagrant ssh')
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ module Kontena::Plugin::Vagrant::Master
2
+ class StartCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+
5
+ def execute
6
+ require_relative '../../../machine/vagrant'
7
+
8
+ vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
9
+ abort("Cannot find Vagrant node kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
10
+ Dir.chdir(vagrant_path) do
11
+ ShellSpinner "Starting Vagrant machine kontena-master " do
12
+ Open3.popen2('vagrant up') do |stdin, output, wait|
13
+ while o = output.gets
14
+ print o if ENV['DEBUG']
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Kontena::Plugin::Vagrant::Master
2
+ class StopCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+
5
+ def execute
6
+ require_relative '../../../machine/vagrant'
7
+
8
+ vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
9
+ abort("Cannot find Vagrant kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
10
+ Dir.chdir(vagrant_path) do
11
+ ShellSpinner "Stopping Vagrant kontena-master " do
12
+ Open3.popen2('vagrant halt') do |stdin, output, wait|
13
+ while o = output.gets
14
+ print o if ENV['DEBUG']
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Kontena::Plugin::Vagrant::Master
2
+ class TerminateCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+
5
+ option '--force', :flag, 'Force remove', default: false, attribute_name: :forced
6
+
7
+ def execute
8
+ require_api_url
9
+
10
+ confirm unless forced?
11
+
12
+ require_relative '../../../machine/vagrant'
13
+ destroyer = destroyer(client(require_token))
14
+ destroyer.run!
15
+ end
16
+
17
+ def destroyer(client)
18
+ Kontena::Machine::Vagrant::MasterDestroyer.new(client)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'master/create_command'
2
+ require_relative 'master/start_command'
3
+ require_relative 'master/stop_command'
4
+ require_relative 'master/restart_command'
5
+ require_relative 'master/ssh_command'
6
+ require_relative 'master/terminate_command'
7
+
8
+ class Kontena::Plugin::Vagrant::MasterCommand < Kontena::Command
9
+
10
+ subcommand "create", "Create a new Vagrant master", Kontena::Plugin::Vagrant::Master::CreateCommand
11
+ subcommand "ssh", "SSH into Vagrant master", Kontena::Plugin::Vagrant::Master::SshCommand
12
+ subcommand "start", "Start Vagrant master", Kontena::Plugin::Vagrant::Master::StartCommand
13
+ subcommand "stop", "Stop Vagrant master", Kontena::Plugin::Vagrant::Master::StopCommand
14
+ subcommand "restart", "Restart Vagrant master", Kontena::Plugin::Vagrant::Master::RestartCommand
15
+ subcommand "terminate", "Terminate Vagrant master", Kontena::Plugin::Vagrant::Master::TerminateCommand
16
+
17
+ def execute
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'nodes/create_command'
2
+ require_relative 'nodes/start_command'
3
+ require_relative 'nodes/stop_command'
4
+ require_relative 'nodes/restart_command'
5
+ require_relative 'nodes/ssh_command'
6
+ require_relative 'nodes/terminate_command'
7
+
8
+ class Kontena::Plugin::Vagrant::NodeCommand < Kontena::Command
9
+
10
+ subcommand "create", "Create a new node to Vagrant", Kontena::Plugin::Vagrant::Nodes::CreateCommand
11
+ subcommand "ssh", "Ssh into Vagrant node", Kontena::Plugin::Vagrant::Nodes::SshCommand
12
+ subcommand "start", "Start Vagrant node", Kontena::Plugin::Vagrant::Nodes::StartCommand
13
+ subcommand "stop", "Stop Vagrant node", Kontena::Plugin::Vagrant::Nodes::StopCommand
14
+ subcommand "restart", "Restart Vagrant node", Kontena::Plugin::Vagrant::Nodes::RestartCommand
15
+ subcommand "terminate", "Terminate Vagrant node", Kontena::Plugin::Vagrant::Nodes::TerminateCommand
16
+
17
+ def execute
18
+ end
19
+ end
@@ -0,0 +1,42 @@
1
+ module Kontena::Plugin::Vagrant::Nodes
2
+ class CreateCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
5
+
6
+ parameter "[NAME]", "Node name"
7
+ option "--instances", "AMOUNT", "How many nodes will be created", default: '1'
8
+ option "--memory", "MEMORY", "How much memory node has", default: '1024'
9
+ option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
10
+
11
+ def execute
12
+ require_api_url
13
+ require_current_grid
14
+
15
+ require_relative '../../../machine/vagrant'
16
+
17
+ grid = fetch_grid
18
+ provisioner = provisioner(client(require_token))
19
+ instances.to_i.times do |i|
20
+ provisioner.run!(
21
+ master_uri: api_url,
22
+ grid_token: grid['token'],
23
+ grid: current_grid,
24
+ name: name,
25
+ instance_number: i + 1,
26
+ memory: memory,
27
+ version: version
28
+ )
29
+ end
30
+ end
31
+
32
+ # @param [Kontena::Client] client
33
+ def provisioner(client)
34
+ Kontena::Machine::Vagrant::NodeProvisioner.new(client)
35
+ end
36
+
37
+ # @return [Hash]
38
+ def fetch_grid
39
+ client(require_token).get("grids/#{current_grid}")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,28 @@
1
+ module Kontena::Plugin::Vagrant::Nodes
2
+ class RestartCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
5
+
6
+ parameter "NAME", "Node name"
7
+
8
+ def execute
9
+ require_api_url
10
+ require_current_grid
11
+
12
+ require_relative '../../../machine/vagrant'
13
+ require 'shell-spinner'
14
+
15
+ vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
16
+ abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
17
+ Dir.chdir(vagrant_path) do
18
+ ShellSpinner "Restarting Vagrant machine #{name.colorize(:cyan)} " do
19
+ Open3.popen2('vagrant reload') do |stdin, output, wait|
20
+ while o = output.gets
21
+ print o if ENV['DEBUG']
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ module Kontena::Plugin::Vagrant::Nodes
2
+ class SshCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
5
+
6
+ parameter "NAME", "Node name"
7
+
8
+ def execute
9
+ require_api_url
10
+ require_current_grid
11
+
12
+ require_relative '../../../machine/vagrant'
13
+
14
+ vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
15
+ abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
16
+
17
+ Dir.chdir(vagrant_path) do
18
+ system('vagrant ssh')
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ module Kontena::Plugin::Vagrant::Nodes
2
+ class StartCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
5
+
6
+ parameter "NAME", "Node name"
7
+
8
+ def execute
9
+ require_api_url
10
+ require_current_grid
11
+
12
+ require_relative '../../../machine/vagrant'
13
+
14
+ vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
15
+ abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
16
+ Dir.chdir(vagrant_path) do
17
+ ShellSpinner "Starting Vagrant machine #{name.colorize(:cyan)} " do
18
+ Open3.popen2('vagrant up') do |stdin, output, wait|
19
+ while o = output.gets
20
+ print o if ENV['DEBUG']
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Kontena::Plugin::Vagrant::Nodes
2
+ class StopCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
5
+
6
+ parameter "NAME", "Node name"
7
+
8
+ def execute
9
+ require_api_url
10
+ require_current_grid
11
+
12
+ require_relative '../../../machine/vagrant'
13
+
14
+ vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
15
+ abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
16
+ Dir.chdir(vagrant_path) do
17
+ ShellSpinner "Stopping Vagrant machine #{name.colorize(:cyan)} " do
18
+ Open3.popen2('vagrant halt') do |stdin, output, wait|
19
+ while o = output.gets
20
+ print o if ENV['DEBUG']
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ module Kontena::Plugin::Vagrant::Nodes
2
+ class TerminateCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
5
+
6
+ parameter "NAME", "Node name"
7
+ option '--force', :flag, 'Force remove', default: false, attribute_name: :forced
8
+
9
+ def execute
10
+ require_api_url
11
+ require_current_grid
12
+
13
+ confirm_command("#{current_grid}/#{name}") unless forced?
14
+
15
+ require_relative '../../../machine/vagrant'
16
+
17
+ destroyer = destroyer(client(require_token))
18
+ destroyer.run!(current_grid, name)
19
+ end
20
+
21
+ # @param [Kontena::Client] client
22
+ def destroyer(client)
23
+ Kontena::Machine::Vagrant::NodeDestroyer.new(client)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ require_relative 'vagrant/master_command'
2
+ require_relative 'vagrant/node_command'
3
+
4
+ class Kontena::Plugin::VagrantCommand < Kontena::Command
5
+
6
+ subcommand 'master', 'Vagrant master related commands', Kontena::Plugin::Vagrant::MasterCommand
7
+ subcommand 'node', 'Vagrant node related commands', Kontena::Plugin::Vagrant::NodeCommand
8
+
9
+ def execute
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ require 'kontena_cli'
2
+ require_relative 'kontena/plugin/vagrant'
3
+ require_relative 'kontena/plugin/vagrant_command'
4
+
5
+ Kontena::MainCommand.register("vagrant", "Vagrant specific commands", Kontena::Plugin::VagrantCommand)
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kontena-plugin-vagrant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kontena, Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kontena-cli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.15.0.rc1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.15.0.rc1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Kontena Vagrant plugin
56
+ email:
57
+ - info@kontena.io
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".gitmodules"
64
+ - ".rspec"
65
+ - ".ruby-gemset"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - kontena-plugin-vagrant.gemspec
70
+ - lib/kontena/machine/vagrant.rb
71
+ - lib/kontena/machine/vagrant/Vagrantfile.master.rb.erb
72
+ - lib/kontena/machine/vagrant/Vagrantfile.node.rb.erb
73
+ - lib/kontena/machine/vagrant/cloudinit.yml
74
+ - lib/kontena/machine/vagrant/master_destroyer.rb
75
+ - lib/kontena/machine/vagrant/master_provisioner.rb
76
+ - lib/kontena/machine/vagrant/node_destroyer.rb
77
+ - lib/kontena/machine/vagrant/node_provisioner.rb
78
+ - lib/kontena/plugin/vagrant.rb
79
+ - lib/kontena/plugin/vagrant/master/create_command.rb
80
+ - lib/kontena/plugin/vagrant/master/restart_command.rb
81
+ - lib/kontena/plugin/vagrant/master/ssh_command.rb
82
+ - lib/kontena/plugin/vagrant/master/start_command.rb
83
+ - lib/kontena/plugin/vagrant/master/stop_command.rb
84
+ - lib/kontena/plugin/vagrant/master/terminate_command.rb
85
+ - lib/kontena/plugin/vagrant/master_command.rb
86
+ - lib/kontena/plugin/vagrant/node_command.rb
87
+ - lib/kontena/plugin/vagrant/nodes/create_command.rb
88
+ - lib/kontena/plugin/vagrant/nodes/restart_command.rb
89
+ - lib/kontena/plugin/vagrant/nodes/ssh_command.rb
90
+ - lib/kontena/plugin/vagrant/nodes/start_command.rb
91
+ - lib/kontena/plugin/vagrant/nodes/stop_command.rb
92
+ - lib/kontena/plugin/vagrant/nodes/terminate_command.rb
93
+ - lib/kontena/plugin/vagrant_command.rb
94
+ - lib/kontena_cli_plugin.rb
95
+ homepage: https://github.com/kontena/kontena-plugin-vagrant
96
+ licenses:
97
+ - Apache-2.0
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.5.1
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Kontena Vagrant plugin
119
+ test_files: []