vagrant-lfstacks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +9 -0
- data/Rakefile +5 -0
- data/Vagrantfile.dev_example +84 -0
- data/lib/commands/bootstrap.rb +51 -0
- data/lib/commands/reimage.rb +47 -0
- data/lib/commands/remaster.rb +75 -0
- data/lib/commands/repuppet.rb +74 -0
- data/lib/commands/s3box.rb +84 -0
- data/lib/vagrant-lfstacks/utils.rb +25 -0
- data/lib/vagrant-lfstacks/version.rb +4 -0
- data/lib/vagrant-lfstacks.rb +56 -0
- data/vagrant-lfstacks.gemspec +28 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4079054be88e06ce0a5cbd1b0fec91738e1991d0
|
4
|
+
data.tar.gz: 2c16a3afe031b4fb44c0396579ba383b8d439be0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b5eb4b5875f71fe041da44fce6901f785a8e12bf0d1f45563af40fc3d12ed2014b64889e2cbbd45f5484b902b28b1191beefd21d3ed627bdb5314e59d846c768
|
7
|
+
data.tar.gz: 7e18592636adb4e12c7ba761d5d7b0482b72f540e1d4e94f900f0fe0845e6d9c50f451d2819ec4cb125e07b9fac04809ab69623510f404c6c5e4f5c4da4f1d60
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'aws-s3', :require => 'aws/s3'
|
4
|
+
gem 'vagrant-dns'
|
5
|
+
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in lfstacks.gemspec
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
group :development do
|
11
|
+
# We depend on Vagrant for development, but we don't add it as a
|
12
|
+
# gem dependency because we expect to be installed within the
|
13
|
+
# Vagrant environment itself using `vagrant plugin`.
|
14
|
+
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
|
15
|
+
gem 'byebug'
|
16
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Navid Khalili
|
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,9 @@
|
|
1
|
+
# Vagrant::Lfstacks
|
2
|
+
|
3
|
+
When doing development work, please remember to set VAGRANT_INTERNAL_BUNDLERIZED=1 on shell upon evocation so that your Gemfile will work!
|
4
|
+
|
5
|
+
Example: VAGRANT_INTERNAL_BUNDLERIZED=1 bundle exec vagrant bootstrap
|
6
|
+
|
7
|
+
A Vagrantfile.dev_example is provided as a resource for development work, but since this Vagrantfile is transient and may contain testing resource (ie broken stuff), use with caution. We will try our best to keep this inline with the main Vagrantfile checked into livefyre/vagrant repo, but DO NOT copy this one over to the main repo as it contains testing directives and includes funky filepaths.
|
8
|
+
|
9
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# THIS IS AN EXAMPLE VAGRANTFILE FOR DEV TESTING. USE ONLY IF YOU KNOW WHAT YOU ARE DOING AND YOU ARE TRYING TO WORK ON VAGRANT-LFSTACKS
|
2
|
+
|
3
|
+
# Vagrant.require_plugin 'lfstacks'
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
require 'bundler/setup'
|
8
|
+
require 'vagrant-dns'
|
9
|
+
|
10
|
+
require 'vagrant-lfstacks'
|
11
|
+
|
12
|
+
require 'yaml'
|
13
|
+
require 'pp'
|
14
|
+
|
15
|
+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
16
|
+
VAGRANTFILE_API_VERSION = "2"
|
17
|
+
|
18
|
+
global_config = {
|
19
|
+
:tld => 'localdev.livefyre.com',
|
20
|
+
:synced_folders => [
|
21
|
+
["#{ENV['HOME']}/dev", '/livefyre'],
|
22
|
+
["#{ENV['HOME']}/dev/lfconfig", '/puppet_configs'],
|
23
|
+
["#{ENV['HOME']}/dev/lfconfig", '/opt/lfconfig'],
|
24
|
+
],
|
25
|
+
:cache => true,
|
26
|
+
:vb_mem => '1024',
|
27
|
+
:vb_cpus => '8',
|
28
|
+
:vbg_auto_update => true,
|
29
|
+
:vb_gui => false,
|
30
|
+
}
|
31
|
+
|
32
|
+
# NK here we grab any overrides
|
33
|
+
|
34
|
+
if File.exists?('./config.d/global_overrides.yaml')
|
35
|
+
overrides = YAML.load_file('./config.d/global_overrides.yaml')
|
36
|
+
global_config.update(overrides)
|
37
|
+
end
|
38
|
+
|
39
|
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
40
|
+
Dir.glob("./stacks.d/*") do |hosts_file|
|
41
|
+
guest_list = YAML.load_file(hosts_file) or abort "Unable to open hosts file..."
|
42
|
+
guest_list.values.each do |guest|
|
43
|
+
# vm_name, domain, image_name, ip_addr, port_forward, *cnames = line.split
|
44
|
+
config.vm.define(guest[:hostname]) do |puppet_config|
|
45
|
+
puppet_config.vm.box = guest[:box]
|
46
|
+
#puppet_config.vm.hostname = "#{vm_name}.#{domain}"
|
47
|
+
config.dns.patterns = /^#{guest[:hostname]}.#{guest[:domain]}$/
|
48
|
+
puppet_config.vm.network "private_network", ip: guest[:ip]
|
49
|
+
#puppet_config.vm.customize ["setextradata", :id, cnames]
|
50
|
+
puppet_config.vm.host_name = "#{guest[:hostname]}.#{guest[:domain]}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
# Common config
|
55
|
+
|
56
|
+
config.dns.tld = global_config[:tld]
|
57
|
+
|
58
|
+
global_config[:synced_folders].each do |synced_folder|
|
59
|
+
config.vm.synced_folder(*synced_folder)
|
60
|
+
end
|
61
|
+
|
62
|
+
# config.cache.auto_detect = true if global_config[:cache]
|
63
|
+
# config.vbguest.auto_update = false unless global_config[:vbg_auto_update]
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
# Provider-specific configuration so you can fine-tune various
|
68
|
+
# backing providers for Vagrant. These expose provider-specific options.
|
69
|
+
# Example for VirtualBox:
|
70
|
+
#
|
71
|
+
config.vm.provider :virtualbox do |vb|
|
72
|
+
# Boot in headless mode or not?
|
73
|
+
vb.gui = global_config[:vb_gui]
|
74
|
+
|
75
|
+
# Use VBoxManage to customize the VM. For example to change memory:
|
76
|
+
vb.customize ["modifyvm", :id, "--memory", global_config[:vb_mem].to_s]
|
77
|
+
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
78
|
+
vb.customize ["modifyvm", :id, "--cpus", global_config[:vb_cpus].to_s]
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class BootstrapCommand < Vagrant.plugin(2, :command)
|
4
|
+
|
5
|
+
# def initialize(argv, env)
|
6
|
+
# @argv = argv
|
7
|
+
# @env = env
|
8
|
+
# @logger = Log4r::Logger.new("vagrant::command::#{self.class.to_s.downcase}")
|
9
|
+
# end
|
10
|
+
|
11
|
+
def self.synopsis
|
12
|
+
"This command bootstraps a running puppet cluster"
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
|
17
|
+
@env.ui.info "Downloading any s3boxes if necessary"
|
18
|
+
require_relative 's3box'
|
19
|
+
S3boxCommand.new(@argv, @env).execute
|
20
|
+
|
21
|
+
if sanity_checks
|
22
|
+
@env.ui.info "Executing repuppet"
|
23
|
+
require_relative 'repuppet'
|
24
|
+
RepuppetCommand.new(@argv,@env).execute
|
25
|
+
else
|
26
|
+
@env.ui.info "Not going to repuppet as box in puppet.yml does not exist"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def sanity_checks
|
32
|
+
|
33
|
+
# passed = true
|
34
|
+
|
35
|
+
@env.ui.info "Doing minor sanity checks"
|
36
|
+
begin
|
37
|
+
puppet_cluster = YAML.load_file("#{@env.root_path}/stacks.d/puppet.yml")
|
38
|
+
rescue Errno::ENOENT => e
|
39
|
+
@env.ui.error "Could not find #{@env.root_path}/stacks.d/puppet.yml"
|
40
|
+
return
|
41
|
+
end
|
42
|
+
local_box_names = @env.boxes.all.map { |b| b[0] }
|
43
|
+
|
44
|
+
# pp local_box_names
|
45
|
+
|
46
|
+
|
47
|
+
return local_box_names.include?(puppet_cluster[:puppet][:box]) && local_box_names.include?(puppet_cluster[:puppetdb][:box])
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
# require_relative 'utils'
|
3
|
+
|
4
|
+
class ReimageCommand < Vagrant.plugin(2, :command)
|
5
|
+
# def initialize(argv, env)
|
6
|
+
# @argv = argv
|
7
|
+
# @env = env
|
8
|
+
# @logger = Log4r::Logger.new("vagrant::command::#{self.class.to_s.downcase}")
|
9
|
+
# end
|
10
|
+
|
11
|
+
|
12
|
+
def self.synopsis
|
13
|
+
"Reimage a machine via puppet"
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
# Parse the options
|
18
|
+
argv = parse_options
|
19
|
+
if argv.length < 1
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
with_target_vms("puppet") do |machine|
|
24
|
+
@env.ui.info "Removing #{machine.name}'s cert on puppet master"
|
25
|
+
argv.each do |target|
|
26
|
+
ssh_cmd machine, "puppet cert clean #{target}.localdev.livefyre.com || true"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
with_target_vms(argv) do |machine|
|
30
|
+
@env.ui.info "Destroying #{machine.name}"
|
31
|
+
machine.action(:destroy, :force_confirm_destroy => true)
|
32
|
+
machine.action(:up)
|
33
|
+
|
34
|
+
# this is hack to get around a bug in the vagrant
|
35
|
+
# initialization.
|
36
|
+
# this is the issue on REHL:
|
37
|
+
# https://github.com/mitchellh/vagrant/pull/1577
|
38
|
+
cycle_iface machine, "eth1"
|
39
|
+
ssh_cmd machine, "rm -rf /var/lib/puppet/"
|
40
|
+
ssh_cmd machine, "/puppet_configs/scripts/ensure_hostname #{machine.name}.localdev.livefyre.com"
|
41
|
+
@env.ui.info "Installing puppet for #{machine.name}"
|
42
|
+
ssh_cmd machine, "/puppet_configs/scripts/ensure_puppet_installed client"
|
43
|
+
@env.ui.info "Running puppet on#{machine.name}"
|
44
|
+
ssh_cmd machine, "/puppet_configs/scripts/ensure_puppet_converged -w"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
# NK *** TODO move debug out into option
|
3
|
+
|
4
|
+
class RemasterCommand < Vagrant.plugin(2, :command)
|
5
|
+
def initialize(argv, env)
|
6
|
+
@argv = argv
|
7
|
+
@env = env
|
8
|
+
@logger = Log4r::Logger.new("vagrant::command::#{self.class.to_s.downcase}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.synopsis
|
12
|
+
"Sets up a new puppet master while recycling the SSL keys on a puppetdb"
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
|
17
|
+
opt_hash = {}
|
18
|
+
opt_hash[:debug] = false
|
19
|
+
v_opts = OptionParser.new do |opts|
|
20
|
+
opts.banner = 'Usage: vargrant remaster [-v]'
|
21
|
+
opts.on( "-d", "--debug", "Add debug level to puppet runs" ) do |opt|
|
22
|
+
opt_hash[:debug] = opt
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# Parse the options
|
26
|
+
argv = parse_options(v_opts)
|
27
|
+
# return unless argv.length == 0
|
28
|
+
|
29
|
+
|
30
|
+
with_target_vms('puppet') do |machine|
|
31
|
+
@env.ui.info "Destroying puppet master"
|
32
|
+
machine.action(:destroy, :force_confirm_destroy=>true)
|
33
|
+
machine.action(:up)
|
34
|
+
|
35
|
+
# this is hack to get around a bug in the vagrant
|
36
|
+
# initialization.
|
37
|
+
# this is the issue on REHL:
|
38
|
+
# https://github.com/mitchellh/vagrant/pull/1577
|
39
|
+
cycle_iface machine, "eth1"
|
40
|
+
@env.ui.info "Bootstrapping puppet master"
|
41
|
+
ssh_cmd machine, "/puppet_configs/scripts/puppet_master_setup.sh puppet.localdev.livefyre.com"
|
42
|
+
|
43
|
+
# ssh_cmd machine, "sudo puppet agent -t --debug"
|
44
|
+
end
|
45
|
+
|
46
|
+
with_target_vms('puppetdb') do |machine|
|
47
|
+
@env.ui.info "Cycling puppet db SSL"
|
48
|
+
|
49
|
+
# NK begin cert regen and jetty cert regen
|
50
|
+
|
51
|
+
ssh_cmd machine, "/puppet_configs/scripts/client_new_master_migration.sh"
|
52
|
+
ssh_cmd machine, "rm -rf /etc/puppetdb/ssl"
|
53
|
+
# NK This is needed since puppetdb-ssl-setup needs the appropriate certs to run and this is the easiest way to get them back
|
54
|
+
# NK current deprecation warning does not allow me to use '-t' (detailed exitcodes)
|
55
|
+
ssh_cmd machine, "sudo puppet agent --no-daemonize --onetime --noop --debug"
|
56
|
+
ssh_cmd machine, "/usr/sbin/puppetdb-ssl-setup"
|
57
|
+
|
58
|
+
# NK end certs regen
|
59
|
+
|
60
|
+
# NK the puppetdb-ssl-setup breaks some init settings, we use puppet to make it right. Also, error_check is true by default...keeping this as an example.
|
61
|
+
ssh_cmd machine, "sudo puppet agent --no-daemonize --onetime --debug", {:error_check => true}
|
62
|
+
end
|
63
|
+
|
64
|
+
with_target_vms('puppet') do |machine|
|
65
|
+
@env.ui.info "NK *** kicking off puppet agent on master"
|
66
|
+
ssh_cmd machine, "sudo puppet agent -t --debug"
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# with_target_vms('puppet') do |machine|
|
71
|
+
# @env.ui.info "Running puppet on puppet master"
|
72
|
+
# ssh_cmd machine, "/puppet_configs/scripts/ensure_puppet_converged -w"
|
73
|
+
# end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
class RepuppetCommand < Vagrant.plugin(2, :command)
|
3
|
+
def initialize(argv, env)
|
4
|
+
@argv = argv
|
5
|
+
@env = env
|
6
|
+
@logger = Log4r::Logger.new("vagrant::command::#{self.class.to_s.downcase}")
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.synopsis
|
10
|
+
"Destroy and bring up a new puppet cluster (puppet master and puppetdb)"
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
# Parse the options
|
15
|
+
argv = parse_options
|
16
|
+
return unless argv.length == 0
|
17
|
+
|
18
|
+
#########################################
|
19
|
+
# Destroy all the puppet infrastructure #
|
20
|
+
#########################################
|
21
|
+
with_target_vms('puppetdb') do |machine|
|
22
|
+
@env.ui.info "Destroying puppet db"
|
23
|
+
machine.action(:destroy, :force_confirm_destroy=>true)
|
24
|
+
end
|
25
|
+
with_target_vms('puppet') do |machine|
|
26
|
+
@env.ui.info "Destroying puppet"
|
27
|
+
machine.action(:destroy, :force_confirm_destroy=>true)
|
28
|
+
end
|
29
|
+
|
30
|
+
###########################################
|
31
|
+
# Rebuild the puppet master in no-db mode #
|
32
|
+
###########################################
|
33
|
+
with_target_vms('puppet') do |machine|
|
34
|
+
@env.ui.info "rebuilding puppet"
|
35
|
+
machine.action(:up)
|
36
|
+
|
37
|
+
# this is hack to get around a bug in the vagrant
|
38
|
+
# initialization.
|
39
|
+
# this is the issue on REHL:
|
40
|
+
# https://github.com/mitchellh/vagrant/pull/1577
|
41
|
+
cycle_iface machine, "eth1"
|
42
|
+
|
43
|
+
@env.ui.info "Bootstrapping puppet master"
|
44
|
+
ssh_cmd machine, "/puppet_configs/scripts/puppet_master_setup.sh puppet.localdev.livefyre.com"
|
45
|
+
end
|
46
|
+
|
47
|
+
########################
|
48
|
+
# Rebuild the puppetdb #
|
49
|
+
########################
|
50
|
+
with_target_vms('puppetdb') do |machine|
|
51
|
+
@env.ui.info "rebuilding puppetdb"
|
52
|
+
machine.action(:up)
|
53
|
+
|
54
|
+
# this is hack to get around a bug in the vagrant
|
55
|
+
# initialization.
|
56
|
+
# this is the issue on REHL:
|
57
|
+
# https://github.com/mitchellh/vagrant/pull/1577
|
58
|
+
cycle_iface machine, "eth1"
|
59
|
+
|
60
|
+
@env.ui.info "Bootstrapping puppetdb"
|
61
|
+
ssh_cmd machine, "/puppet_configs/scripts/puppet_db_setup.sh puppetdb.localdev.livefyre.com"
|
62
|
+
@env.ui.info "Running puppet on puppet db"
|
63
|
+
ssh_cmd machine, "/puppet_configs/scripts/ensure_puppet_converged -w"
|
64
|
+
end
|
65
|
+
|
66
|
+
#####################################
|
67
|
+
# Re-enable store configs in puppet #
|
68
|
+
#####################################
|
69
|
+
with_target_vms('puppet') do |machine|
|
70
|
+
@env.ui.info "Running puppet on puppet master"
|
71
|
+
ssh_cmd machine, "/puppet_configs/scripts/ensure_puppet_converged -w"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'aws/s3'
|
3
|
+
|
4
|
+
|
5
|
+
#class BootstrapCommand < Vagrant::Command::Base
|
6
|
+
class S3boxCommand < Vagrant.plugin(2, :command)
|
7
|
+
|
8
|
+
|
9
|
+
def self.synopsis
|
10
|
+
"This command updates available boxes from an s3 repo. See README for where to put AWS creds. Virtualbox provider currently assumed"
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
|
15
|
+
opt_hash = {}
|
16
|
+
opt_hash[:clean] = false
|
17
|
+
v_opts = OptionParser.new do |opts|
|
18
|
+
opts.banner = 'Usage: vagrant s3box [-c] '
|
19
|
+
opts.on( "-c", "--clean", "Remove boxes which are no longer backed by S3" ) do |opt|
|
20
|
+
opt_hash[:clean] = opt
|
21
|
+
end
|
22
|
+
opts.on( "-p", "--pretend","Pretend but don't actually do anything" ) do |opt|
|
23
|
+
opt_hash[:pretend] = opt
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
argv = parse_options(v_opts)
|
28
|
+
|
29
|
+
|
30
|
+
begin
|
31
|
+
aws_creds = YAML.load_file("#{ENV['HOME']}/.s3_keys")
|
32
|
+
rescue Exception => e
|
33
|
+
@env.ui.error "You need a valid .s3_keys yaml file in your HOME dir, currently using: #{ENV['HOME']} as HOME path See README for details"
|
34
|
+
end
|
35
|
+
|
36
|
+
AWS::S3::Base.establish_connection!(aws_creds)
|
37
|
+
|
38
|
+
s3_boxes = AWS::S3::Bucket.find 'livefyre-vagrant-boxes'
|
39
|
+
|
40
|
+
boxes_to_check = s3_boxes.select {|box| argv.include?(File.basename(box.key, '.box'))} unless argv.empty?
|
41
|
+
boxes_to_check ||= s3_boxes
|
42
|
+
# @env.ui.info boxes_to_check.inspect
|
43
|
+
|
44
|
+
# Create or update boxes from S3
|
45
|
+
|
46
|
+
boxes_to_check.each do |s3_box|
|
47
|
+
box_name = File.basename(s3_box.key, '.box')
|
48
|
+
local_box = @env.boxes.find(box_name, 'virtualbox')
|
49
|
+
unless local_box.nil?
|
50
|
+
local_date = DateTime.parse File.mtime(local_box.directory).to_s
|
51
|
+
s3_date = DateTime.parse s3_box.about['last-modified']
|
52
|
+
end
|
53
|
+
|
54
|
+
if opt_hash[:pretend]
|
55
|
+
@env.ui.info "Would add/update: #{box_name}, but skipping due to pretend" if (local_box.nil? || (s3_date > local_date))
|
56
|
+
else
|
57
|
+
# NK stupid force will result in an error instead of skipping if I try to add an existing box that doesn't need an update
|
58
|
+
if (local_box.nil? || (s3_date > local_date))
|
59
|
+
@env.action_runner.run(Vagrant::Action.action_box_add, {
|
60
|
+
:box_name => box_name,
|
61
|
+
:box_provider => 'virtualbox',
|
62
|
+
:box_url => s3_box.url,
|
63
|
+
:box_force => (!local_box.nil? && (s3_date > local_date))
|
64
|
+
})
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# Remove local boxes no longer on S3
|
71
|
+
if opt_hash[:clean]
|
72
|
+
box_list = boxes_to_check.map {|b| File.basename(b.key, '.box')}
|
73
|
+
@env.boxes.all.each do |local_box|
|
74
|
+
local_box_name = local_box[0]
|
75
|
+
if opt_hash[:pretend]
|
76
|
+
@env.ui.info "Would remove #{local_box_name} but skipping due to pretend" unless box_list.include?(local_box_name)
|
77
|
+
else
|
78
|
+
@env.boxes.find(local_box_name, 'virtualbox').destroy! unless box_list.include?(local_box_name)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end #end execute
|
84
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
def ssh_cmd(machine, cmd, opts = {})
|
3
|
+
machine.communicate.tap do |comm|
|
4
|
+
comm.sudo(cmd, opts) do |type, data|
|
5
|
+
if !data.empty?
|
6
|
+
machine.env.ui.info(data, :new_line => false, :prefix => false)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_next_ip(current_ip)
|
13
|
+
ip = current_ip.split "."
|
14
|
+
ip[3] = String(Integer(ip[3])+1)
|
15
|
+
ip.join(".")
|
16
|
+
end
|
17
|
+
|
18
|
+
def cycle_iface(machine, iface)
|
19
|
+
ssh_cmd(machine, "/sbin/ifdown #{iface}")
|
20
|
+
ssh_cmd(machine, "/sbin/ifup #{iface}")
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "This plugin must run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
require "vagrant-lfstacks/version"
|
8
|
+
require 'vagrant-lfstacks/utils'
|
9
|
+
|
10
|
+
module Lfstacks
|
11
|
+
|
12
|
+
|
13
|
+
class Plugin < Vagrant.plugin("2")
|
14
|
+
|
15
|
+
name "LfStacks Plugin"
|
16
|
+
description "Livefyre's Vagrant Plugins for stack related work"
|
17
|
+
|
18
|
+
command 's3box' do
|
19
|
+
require_relative 'commands/s3box'
|
20
|
+
S3boxCommand
|
21
|
+
end
|
22
|
+
|
23
|
+
command "bootstrap" do
|
24
|
+
require_relative 'commands/bootstrap'
|
25
|
+
BootstrapCommand
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
command "reimage" do
|
30
|
+
require_relative 'commands/reimage'
|
31
|
+
ReimageCommand
|
32
|
+
end
|
33
|
+
|
34
|
+
command 'repuppet' do
|
35
|
+
require_relative 'commands/repuppet'
|
36
|
+
RepuppetCommand
|
37
|
+
end
|
38
|
+
|
39
|
+
command 'remaster' do
|
40
|
+
require_relative 'commands/remaster'
|
41
|
+
RemasterCommand
|
42
|
+
end
|
43
|
+
|
44
|
+
command "bootstrap" do
|
45
|
+
require_relative 'commands/bootstrap'
|
46
|
+
BootstrapCommand
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-lfstacks/version'
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
Gem::Specification.new do |spec|
|
10
|
+
spec.name = "vagrant-lfstacks"
|
11
|
+
spec.version = Lfstacks::VERSION
|
12
|
+
spec.authors = ["Navid Khalili"]
|
13
|
+
spec.email = ["navid@wegeeks.us"]
|
14
|
+
spec.description = %q{Livefyre's vagrant stack management tasks}
|
15
|
+
spec.summary = %q{Livefyre's vagrant stack management tasks}
|
16
|
+
spec.homepage = ""
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files`.split($/)
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
|
27
|
+
spec.add_dependency "aws-s3", "~> 0.6.3"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-lfstacks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Navid Khalili
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-17 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-s3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.6.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.6.3
|
55
|
+
description: Livefyre's vagrant stack management tasks
|
56
|
+
email:
|
57
|
+
- navid@wegeeks.us
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- Vagrantfile.dev_example
|
68
|
+
- lib/commands/bootstrap.rb
|
69
|
+
- lib/commands/reimage.rb
|
70
|
+
- lib/commands/remaster.rb
|
71
|
+
- lib/commands/repuppet.rb
|
72
|
+
- lib/commands/s3box.rb
|
73
|
+
- lib/vagrant-lfstacks.rb
|
74
|
+
- lib/vagrant-lfstacks/utils.rb
|
75
|
+
- lib/vagrant-lfstacks/version.rb
|
76
|
+
- vagrant-lfstacks.gemspec
|
77
|
+
homepage: ''
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.0.6
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Livefyre's vagrant stack management tasks
|
101
|
+
test_files: []
|