vagrant-fleet 0.0.1.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +2 -0
- data/Vagrantfile +61 -0
- data/lib/vagrant-fleet/config.rb +38 -0
- data/lib/vagrant-fleet/local_client.rb +58 -0
- data/lib/vagrant-fleet/plugin.rb +29 -0
- data/lib/vagrant-fleet/provisioner.rb +21 -0
- data/lib/vagrant-fleet/remote_client.rb +39 -0
- data/lib/vagrant-fleet/version.rb +5 -0
- data/lib/vagrant-fleet.rb +12 -0
- data/locales/en.yml +6 -0
- data/redis.service +10 -0
- data/user-data +17 -0
- data/vagrant-fleet.gemspec +23 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b678e90f43c50aa9f3f18d3b22adc027ab0e9171
|
4
|
+
data.tar.gz: 4895fad6024048ca76ee1b7f84252ba6a94b2e48
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c55f330f8573cfa78a432796ba1a69a46c96cc24af2273f79988b6081423e091f06355a5f60bc9bae540b3c1114b5caae6d37f4d26a652feeb20464408b818a5
|
7
|
+
data.tar.gz: adad3f61413016583ed29de86857b85917e4e4539ad7784786f3efb16c330eba471ebfb41be1f1970ddf446dd358c864aa0daff7c367069099ddb662ab2ac90d
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.vagrant
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alex Arnell
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Vagrant Fleet Provisioner
|
2
|
+
|
3
|
+
Vagrant fleet provisioner for use with a CoreOS guest machine
|
4
|
+
|
5
|
+
## Strong Warnings
|
6
|
+
|
7
|
+
This is very early work.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install it as a Vagrant plugin
|
12
|
+
|
13
|
+
$ vagrant plugin install vagrant-fleet --plugin-prerelease
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
TODO: Write usage instructions here
|
18
|
+
|
19
|
+
For now, have a look at the [Vagrantfile](Vagrantfile)
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
1. Fork it ( https://github.com/voidlock/vagrant-fleet/fork )
|
24
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
25
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
26
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
27
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/Vagrantfile
ADDED
@@ -0,0 +1,61 @@
|
|
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.box = "yungsang/coreos-alpha"
|
9
|
+
|
10
|
+
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
11
|
+
config.vm.provision :file, source: "./user-data", destination: "/tmp/vagrantfile-user-data"
|
12
|
+
|
13
|
+
config.vm.provision :shell do |sh|
|
14
|
+
sh.privileged = true
|
15
|
+
sh.inline = <<-EOT
|
16
|
+
mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/
|
17
|
+
EOT
|
18
|
+
end
|
19
|
+
config.vm.provision :fleet do |fleet|
|
20
|
+
|
21
|
+
# Starts the service assuming service exists in local directory with given
|
22
|
+
# name
|
23
|
+
fleet.submit "redis.service"
|
24
|
+
fleet.start "redis.service"
|
25
|
+
|
26
|
+
# fleet.start "path/to/service/file.service"
|
27
|
+
|
28
|
+
# Stops the service
|
29
|
+
# fleet.stop "stop-some.service"
|
30
|
+
|
31
|
+
# To schedule a unit into the cluster (i.e. load it on a machine) without
|
32
|
+
# starting it.
|
33
|
+
#
|
34
|
+
# This will not call the equivalent of systemctl start, so the loaded unit
|
35
|
+
# will be in an inactive state.
|
36
|
+
# fleet.load "load-some.service"
|
37
|
+
|
38
|
+
# Units can also be unscheduled, but remain in the cluster with fleetctl
|
39
|
+
# unload. The unit will still be visible in fleetctl list-unit-files, but
|
40
|
+
# will have no state reported in fleetctl list-units
|
41
|
+
# fleet.unload "unload-some.service"
|
42
|
+
|
43
|
+
# Submission of units to a fleet cluster does not cause them to be
|
44
|
+
# scheduled. The unit will be visible in a fleetctl list-unit-files
|
45
|
+
# command, but have no reported state in fleetctl list-units.
|
46
|
+
# fleet.submit "submit-some.service"
|
47
|
+
|
48
|
+
# The destroy command does two things:
|
49
|
+
#
|
50
|
+
# 1) Instruct systemd on the host machine to stop the unit, deferring to
|
51
|
+
# systemd completely for any custom stop directives (i.e. ExecStop option
|
52
|
+
# in the unit file).
|
53
|
+
# 2) Remove the unit file from the cluster, making it
|
54
|
+
# impossible to start again until it has been re-submitted.
|
55
|
+
#
|
56
|
+
# Once a unit is destroyed, state will continue to be reported for it in
|
57
|
+
# fleetctl list-units. Only once the unit has stopped will its state be
|
58
|
+
# removed.
|
59
|
+
# fleet.destroy "destroy-some.service"
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module FleetProvisioner
|
3
|
+
class Config < Vagrant.plugin("2", :config)
|
4
|
+
def initialize
|
5
|
+
@__submit = Hash.new { |h, k| h[k] = {} }
|
6
|
+
@__units = Hash.new { |h, k| h[k] = {} }
|
7
|
+
end
|
8
|
+
|
9
|
+
def submit_units
|
10
|
+
@__submit
|
11
|
+
end
|
12
|
+
|
13
|
+
def units
|
14
|
+
@__units
|
15
|
+
end
|
16
|
+
|
17
|
+
def start(unit, **options)
|
18
|
+
@__units[unit.to_s] = options.dup
|
19
|
+
end
|
20
|
+
|
21
|
+
def stop(unit)
|
22
|
+
end
|
23
|
+
|
24
|
+
def load(unit)
|
25
|
+
end
|
26
|
+
|
27
|
+
def unload(unit)
|
28
|
+
end
|
29
|
+
|
30
|
+
def submit(unit, **options)
|
31
|
+
@__submit[unit.to_s] = options.dup
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy(unit)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module FleetProvisioner
|
3
|
+
class LocalClient
|
4
|
+
def initialize(machine)
|
5
|
+
@machine = machine
|
6
|
+
end
|
7
|
+
|
8
|
+
def submit_units(units)
|
9
|
+
@machine.communicate.tap do |comm|
|
10
|
+
remote_temp_dir = Pathname.new "/tmp/fleet_#{Time.now.to_i}_#{rand(100000)}"
|
11
|
+
comm.execute("mkdir #{remote_temp_dir}") do |type, data|
|
12
|
+
handle_comm(type, data)
|
13
|
+
end
|
14
|
+
|
15
|
+
units.each do |unit, opts|
|
16
|
+
# Upload the temp file to the remote machine
|
17
|
+
remote_temp = remote_temp_dir.join(unit)
|
18
|
+
@machine.communicate.upload(unit, remote_temp)
|
19
|
+
|
20
|
+
@machine.ui.info(I18n.t("vagrant.fleet_provisioner.fleet_start_unit", unit: unit))
|
21
|
+
comm.execute("fleetctl submit #{remote_temp}") do |type, data|
|
22
|
+
handle_comm(type, data)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
def start_units(units)
|
28
|
+
@machine.communicate.tap do |comm|
|
29
|
+
units.each do |unit, opts|
|
30
|
+
@machine.ui.info(I18n.t("vagrant.fleet_provisioner.fleet_start_unit", unit: unit))
|
31
|
+
comm.execute("fleetctl start #{unit}") do |type, data|
|
32
|
+
handle_comm(type, data)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
# This handles outputting the communication data back to the UI
|
41
|
+
def handle_comm(type, data)
|
42
|
+
if [:stderr, :stdout].include?(type)
|
43
|
+
# Output the data with the proper color based on the stream.
|
44
|
+
# color = type == :stdout ? :green : :red
|
45
|
+
|
46
|
+
# Clear out the newline since we add one
|
47
|
+
data = data.chomp
|
48
|
+
return if data.empty?
|
49
|
+
|
50
|
+
options = {}
|
51
|
+
#options[:color] = color if !config.keep_color
|
52
|
+
|
53
|
+
@machine.ui.info(data.chomp, options)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module FleetProvisioner
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "vagrant-fleet"
|
7
|
+
description <<-DESC
|
8
|
+
A vagrant CoreOS Fleet provisioner plugin
|
9
|
+
DESC
|
10
|
+
|
11
|
+
config(:fleet, :provisioner) do
|
12
|
+
require_relative "config"
|
13
|
+
Config
|
14
|
+
end
|
15
|
+
|
16
|
+
provisioner "fleet" do
|
17
|
+
setup_i18n
|
18
|
+
|
19
|
+
require_relative "provisioner"
|
20
|
+
Provisioner
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.setup_i18n
|
24
|
+
I18n.load_path << File.expand_path("locales/en.yml", FleetProvisioner.source_root)
|
25
|
+
I18n.reload!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "local_client"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module FleetProvisioner
|
5
|
+
class Provisioner < Vagrant.plugin(2, :provisioner)
|
6
|
+
def initialize(machine, config, client = nil)
|
7
|
+
super(machine, config)
|
8
|
+
|
9
|
+
@client = client || LocalClient.new(@machine)
|
10
|
+
end
|
11
|
+
|
12
|
+
def configure(root_config)
|
13
|
+
end
|
14
|
+
|
15
|
+
def provision
|
16
|
+
@client.submit_units(@config.submit_units)
|
17
|
+
@client.start_units(@config.units)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module FleetProvisioner
|
3
|
+
class RemoteClient
|
4
|
+
def initialize(machine)
|
5
|
+
@machine = machine
|
6
|
+
end
|
7
|
+
|
8
|
+
def start_units(units)
|
9
|
+
@machine.communicate.tap do |comm|
|
10
|
+
units.each do |unit, opts|
|
11
|
+
@machine.ui.info(I18n.t("vagrant.fleet_provisioner.fleet_start_unit", unit: unit))
|
12
|
+
comm.sudo("fleetctl start #{unit}") do |type, data|
|
13
|
+
handle_comm(type, data)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
# This handles outputting the communication data back to the UI
|
22
|
+
def handle_comm(type, data)
|
23
|
+
if [:stderr, :stdout].include?(type)
|
24
|
+
# Output the data with the proper color based on the stream.
|
25
|
+
# color = type == :stdout ? :green : :red
|
26
|
+
|
27
|
+
# Clear out the newline since we add one
|
28
|
+
data = data.chomp
|
29
|
+
return if data.empty?
|
30
|
+
|
31
|
+
options = {}
|
32
|
+
#options[:color] = color if !config.keep_color
|
33
|
+
|
34
|
+
@machine.ui.info(data.chomp, options)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/locales/en.yml
ADDED
data/redis.service
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Redis
|
3
|
+
|
4
|
+
[Service]
|
5
|
+
TimeoutStartSec=0
|
6
|
+
ExecStartPre=-/usr/bin/docker kill redis
|
7
|
+
ExecStartPre=-/usr/bin/docker rm redis
|
8
|
+
ExecStartPre=/usr/bin/docker pull dockerfile/redis
|
9
|
+
ExecStart=/usr/bin/docker run --rm --name redis dockerfile/redis
|
10
|
+
ExecStop=/usr/bin/docker stop redis
|
data/user-data
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#cloud-config
|
2
|
+
|
3
|
+
coreos:
|
4
|
+
etcd:
|
5
|
+
addr: $public_ipv4:4001
|
6
|
+
peer-addr: $public_ipv4:7001
|
7
|
+
|
8
|
+
fleet:
|
9
|
+
public-ip: $public_ipv4
|
10
|
+
metadata: name=%NAME%
|
11
|
+
|
12
|
+
units:
|
13
|
+
- name: etcd.service
|
14
|
+
command: start
|
15
|
+
|
16
|
+
- name: fleet.service
|
17
|
+
command: start
|
@@ -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 'vagrant-fleet/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-fleet"
|
8
|
+
spec.version = VagrantPlugins::FleetProvisioner::VERSION
|
9
|
+
spec.authors = ["Alex Arnell"]
|
10
|
+
spec.email = ["alex.arnell@gmail.com"]
|
11
|
+
spec.summary = %q{Vagrant Fleet Provisioner}
|
12
|
+
spec.description = %q{Vagrant fleet provisioner for use with a CoreOS guest machine}
|
13
|
+
spec.homepage = "https://github.com/voidlock/vagrant-fleet"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-fleet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Arnell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Vagrant fleet provisioner for use with a CoreOS guest machine
|
42
|
+
email:
|
43
|
+
- alex.arnell@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- Vagrantfile
|
54
|
+
- lib/vagrant-fleet.rb
|
55
|
+
- lib/vagrant-fleet/config.rb
|
56
|
+
- lib/vagrant-fleet/local_client.rb
|
57
|
+
- lib/vagrant-fleet/plugin.rb
|
58
|
+
- lib/vagrant-fleet/provisioner.rb
|
59
|
+
- lib/vagrant-fleet/remote_client.rb
|
60
|
+
- lib/vagrant-fleet/version.rb
|
61
|
+
- locales/en.yml
|
62
|
+
- redis.service
|
63
|
+
- user-data
|
64
|
+
- vagrant-fleet.gemspec
|
65
|
+
homepage: https://github.com/voidlock/vagrant-fleet
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.3.1
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.2.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Vagrant Fleet Provisioner
|
89
|
+
test_files: []
|