vagrant-opsworks 0.0.5
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/.simplecov +7 -0
- data/.travis.yml +13 -0
- data/Gemfile +44 -0
- data/Guardfile +17 -0
- data/Thorfile +59 -0
- data/integration/Gemfile +11 -0
- data/integration/Vagrantfile +8 -0
- data/lib/berkshelf-monkey-patch.rb +26 -0
- data/lib/vagrant-opsworks/action/checkout_cookbooks.rb +71 -0
- data/lib/vagrant-opsworks/action/configure_berks.rb +26 -0
- data/lib/vagrant-opsworks/action/configure_chef.rb +28 -0
- data/lib/vagrant-opsworks/action/create_roles.rb +69 -0
- data/lib/vagrant-opsworks/action/inject_boxes.rb +44 -0
- data/lib/vagrant-opsworks/action/merge_cookbooks.rb +27 -0
- data/lib/vagrant-opsworks/action/setup_environment.rb +34 -0
- data/lib/vagrant-opsworks/action.rb +51 -0
- data/lib/vagrant-opsworks/application.rb +26 -0
- data/lib/vagrant-opsworks/client/app.rb +50 -0
- data/lib/vagrant-opsworks/client/instance.rb +23 -0
- data/lib/vagrant-opsworks/client/layer.rb +39 -0
- data/lib/vagrant-opsworks/client/stack.rb +47 -0
- data/lib/vagrant-opsworks/client.rb +46 -0
- data/lib/vagrant-opsworks/client_old.rb +94 -0
- data/lib/vagrant-opsworks/config.rb +156 -0
- data/lib/vagrant-opsworks/custom_json.rb +22 -0
- data/lib/vagrant-opsworks/env.rb +19 -0
- data/lib/vagrant-opsworks/env_old.rb +162 -0
- data/lib/vagrant-opsworks/errors.rb +13 -0
- data/lib/vagrant-opsworks/loader/client.rb +19 -0
- data/lib/vagrant-opsworks/loader/instances.rb +78 -0
- data/lib/vagrant-opsworks/loader/stack.rb +27 -0
- data/lib/vagrant-opsworks/loader.rb +24 -0
- data/lib/vagrant-opsworks/plugin.rb +32 -0
- data/lib/vagrant-opsworks/stack/app.rb +0 -0
- data/lib/vagrant-opsworks/stack/instance.rb +62 -0
- data/lib/vagrant-opsworks/stack/stack.rb +84 -0
- data/lib/vagrant-opsworks/stack.rb +20 -0
- data/lib/vagrant-opsworks/util/configuration_builder.rb +44 -0
- data/lib/vagrant-opsworks/util/configuration_hash.rb +27 -0
- data/lib/vagrant-opsworks/util/dummy_configuration.rb +33 -0
- data/lib/vagrant-opsworks/util/env_helpers.rb +44 -0
- data/lib/vagrant-opsworks/version.rb +5 -0
- data/lib/vagrant-opsworks.rb +24 -0
- data/locales/en.yml +13 -0
- data/provisioning/client.yml +16 -0
- data/provisioning/install-agent.sh +75 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/unit/vagrant-opsworks/action/create_roles_spec.rb +5 -0
- data/spec/unit/vagrant-opsworks/config_spec.rb +109 -0
- data/vagrant-opsworks.gemspec +34 -0
- metadata +199 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 766caa1de0d13b688ce42c9b608db05752182e67
|
4
|
+
data.tar.gz: 02981e7a488c63fe05f42c5e242771b51f373ce9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 243fe0387d0ca9789ffafc4a66bffe8447094ffc12752c128a12326106a30bf44547a4c56003c11467bef5f68946cd585e217e9537a4d0f85796722bac6ee97b
|
7
|
+
data.tar.gz: f57d48e251a93043b5133a6f21647c3ae2c32da4653e77a9b1b2bf158a807301fcd130ab0c71fcfb270234338b51f4e04b4fb2496646df5eab19fdffbd496fdb
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
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
|
+
.rspec
|
19
|
+
.vagrant
|
20
|
+
integration/Berksfile.lock
|
data/.simplecov
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
- 2.1.0
|
5
|
+
bundler_args: --without doc guard --jobs 7
|
6
|
+
script: bundle exec thor spec:ci
|
7
|
+
notifications:
|
8
|
+
hipchat:
|
9
|
+
rooms:
|
10
|
+
secure: C+gu4OY+FNhJPrm7HbNvn82C7VEU3G+BRSFeSRpZc6hfKkDOKghTLFlc1NjLKyPdFk6t4qSa4pptUwH9TP+ytImBqqM6BPD8eviO493j1bclXNnNxW+RytCpAwvQTcOVDalzBFvx/jA0uGpAuitBubgpmAhPHc9ddtOnKbEuxEM=
|
11
|
+
template:
|
12
|
+
- '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}'
|
13
|
+
- '%Build details: %{build_url}'
|
data/Gemfile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- mode: ruby; encoding: utf-8 -*-
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
gemspec :path => '.'
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'vagrant', github: 'mitchellh/vagrant', tag: 'v1.6.3'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :plugins do
|
11
|
+
gem 'vagrant-opsworks', path: '.'
|
12
|
+
gem 'vagrant-berkshelf', github: 'berkshelf/vagrant-berkshelf', tag: 'v3.0.1'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :guard do
|
16
|
+
gem 'coolline'
|
17
|
+
gem 'fuubar'
|
18
|
+
gem 'guard', '>= 1.5.0'
|
19
|
+
gem 'guard-rspec'
|
20
|
+
gem 'guard-spork'
|
21
|
+
gem 'guard-yard'
|
22
|
+
gem 'redcarpet'
|
23
|
+
gem 'yard'
|
24
|
+
|
25
|
+
require 'rbconfig'
|
26
|
+
|
27
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
28
|
+
gem 'growl', require: false
|
29
|
+
gem 'rb-fsevent', require: false
|
30
|
+
|
31
|
+
if `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
|
32
|
+
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
33
|
+
end rescue Errno::ENOENT
|
34
|
+
|
35
|
+
elsif RbConfig::CONFIG['target_os'] =~ /linux/i
|
36
|
+
gem 'libnotify', '~> 0.8.0', require:false
|
37
|
+
gem 'rb-inotify', require: false
|
38
|
+
|
39
|
+
elsif RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
40
|
+
gem 'rb-notifu', '>= 0.0.4', require: false
|
41
|
+
gem 'wdm', require: false
|
42
|
+
gem 'win32console', require: false
|
43
|
+
end
|
44
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- mode: ruby; encoding: utf-8 -*-
|
2
|
+
guard 'yard', stdout: '/dev/null', stderr: '/dev/null', port: '8808' do
|
3
|
+
watch(%r{app/.+\.rb})
|
4
|
+
watch(%r{lib/.+\.rb})
|
5
|
+
watch(%r{ext/.+\.c})
|
6
|
+
end
|
7
|
+
|
8
|
+
guard 'spork' do
|
9
|
+
watch('Gemfile')
|
10
|
+
watch('spec/spec_helper.rb') { :rspec }
|
11
|
+
end
|
12
|
+
|
13
|
+
guard 'rspec', cmd: 'bundle exec rspec --color --drb --format Fuubar', all_on_start: false, all_after_pass: false do
|
14
|
+
watch(%r{^spec/unit/.+_spec\.rb$})
|
15
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
|
16
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
17
|
+
end
|
data/Thorfile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- mode: ruby; encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'bundler'
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'thor/rake_compat'
|
7
|
+
require 'vagrant-opsworks'
|
8
|
+
|
9
|
+
GEM_PKG = "vagrant-opsworks-#{VagrantPlugins::OpsWorks::VERSION}.gem".freeze
|
10
|
+
|
11
|
+
class Gem < Thor
|
12
|
+
include Thor::RakeCompat
|
13
|
+
Bundler::GemHelper.install_tasks
|
14
|
+
|
15
|
+
desc 'build', "Build #{GEM_PKG} into the pkg directory"
|
16
|
+
def build
|
17
|
+
Rake::Task['build'].execute
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'release', "Create tag v#{VagrantPlugins::OpsWorks::VERSION} and build and push #{GEM_PKG} to Rubygems"
|
21
|
+
def release
|
22
|
+
Rake::Task['release'].execute
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'install', "Build and install #{GEM_PKG} into system gems"
|
26
|
+
def install
|
27
|
+
Rake::Task['install'].execute
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Spec < Thor
|
32
|
+
include Thor::Actions
|
33
|
+
default_task :unit
|
34
|
+
|
35
|
+
desc 'plug', "Install #{GEM_PKG} into vagrant"
|
36
|
+
def plug
|
37
|
+
build
|
38
|
+
run "vagrant plugin install pkg/#{GEM_PKG}"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'ci', "Run all possible tests on Travis-CI"
|
42
|
+
def ci
|
43
|
+
ENV['CI'] = 'true' # Tracis-CI also sets this, but set it here for local testing
|
44
|
+
invoke(:unit)
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'unit', "Run unit tests"
|
48
|
+
def unit
|
49
|
+
unless run_unit
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
no_tasks do
|
55
|
+
def run_unit(*flags)
|
56
|
+
run "rspec --color --format=documentation #{flags.join(' ')} spec"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/integration/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# -*- mode: ruby; encoding: utf-8 -*-
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
group :development do
|
5
|
+
gem 'vagrant', github: 'mitchellh/vagrant', tag: 'v1.6.3'
|
6
|
+
end
|
7
|
+
|
8
|
+
group :plugins do
|
9
|
+
gem 'vagrant-opsworks', path: '../'
|
10
|
+
gem 'vagrant-berkshelf', github: 'berkshelf/vagrant-berkshelf', tag: 'v3.0.1'
|
11
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'berkshelf/vagrant'
|
2
|
+
require 'berkshelf/vagrant/action'
|
3
|
+
|
4
|
+
module Berkshelf
|
5
|
+
module Vagrant
|
6
|
+
module Action
|
7
|
+
require 'vagrant-opsworks/action'
|
8
|
+
include VagrantPlugins::OpsWorks::Action
|
9
|
+
|
10
|
+
class << self
|
11
|
+
alias_method :old_setup, :setup
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.setup
|
15
|
+
@setup ||= old_setup.tap do |b|
|
16
|
+
b.use ::Vagrant::Action::Builtin::EnvSet, opsworks: VagrantPlugins::OpsWorks::Env.new
|
17
|
+
b.use VagrantPlugins::OpsWorks::Action::SetupEnvironment
|
18
|
+
b.use VagrantPlugins::OpsWorks::Action::CheckoutCookbooks
|
19
|
+
b.use VagrantPlugins::OpsWorks::Action::MergeCookbooks
|
20
|
+
b.use VagrantPlugins::OpsWorks::Action::ConfigureChef
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpsWorks
|
3
|
+
module Action
|
4
|
+
class CheckoutCookbooks
|
5
|
+
include VagrantPlugins::OpsWorks::Util::EnvHelpers
|
6
|
+
require 'git'
|
7
|
+
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
return @app.call(env) unless enabled?(env)
|
14
|
+
|
15
|
+
setup_repo_directory(env)
|
16
|
+
|
17
|
+
opsworks_cookbooks = {
|
18
|
+
:url => 'git@github.com:aws/opsworks-cookbooks.git',
|
19
|
+
:ref => "release-chef-#{env[:opsworks].client.stack.configuration_manager[:version]}"
|
20
|
+
}
|
21
|
+
|
22
|
+
env[:opsworks].ui.info(I18n.t('vagrant_opsworks.action.cookbooks.checkout', {
|
23
|
+
:repo_name => 'OpsWorks cookbooks',
|
24
|
+
:repo_url => opsworks_cookbooks[:url],
|
25
|
+
:ref => opsworks_cookbooks[:ref]
|
26
|
+
}))
|
27
|
+
prepare_cookbooks(:opsworks, opsworks_cookbooks)
|
28
|
+
|
29
|
+
if env[:opsworks].client.stack.custom_cookbooks?
|
30
|
+
custom_cookbooks = {
|
31
|
+
:type => 'git',
|
32
|
+
:url => env[:opsworks].client.stack.custom_cookbooks_source[:url],
|
33
|
+
:ref => env[:opsworks].client.stack.custom_cookbooks_source[:revision]
|
34
|
+
}
|
35
|
+
|
36
|
+
if env[:opsworks].client.stack.custom_cookbooks_source[:type] == 'git'
|
37
|
+
env[:opsworks].ui.info(I18n.t('vagrant_opsworks.action.cookbooks.checkout', {
|
38
|
+
:repo_name => 'custom cookbooks',
|
39
|
+
:repo_url => custom_cookbooks[:url],
|
40
|
+
:ref => custom_cookbooks[:ref]
|
41
|
+
}))
|
42
|
+
prepare_cookbooks(:custom, custom_cookbooks)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
@app.call(env)
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def setup_repo_directory(env)
|
52
|
+
@repo_path = env[:opsworks].data_directory.join('cookbooks').tap{|f| FileUtils.mkdir_p(f) unless f.file? }
|
53
|
+
end
|
54
|
+
|
55
|
+
def prepare_cookbooks(type, settings)
|
56
|
+
repo = @repo_path.join(type.to_s).tap{|d|
|
57
|
+
FileUtils.mkdir_p(d) unless d.file?
|
58
|
+
}
|
59
|
+
if (Dir.entries(repo) - %w{ . .. }).empty?
|
60
|
+
g = Git.clone(settings[:url], type.to_s, :path => @repo_path)
|
61
|
+
else
|
62
|
+
g = Git.open(repo)
|
63
|
+
end
|
64
|
+
|
65
|
+
g.checkout(settings[:ref])
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpsWorks
|
3
|
+
module Action
|
4
|
+
class ConfigureBerks
|
5
|
+
include VagrantPlugins::OpsWorks::Util::EnvHelpers
|
6
|
+
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
return @app.call(env) unless enabled?(env)
|
13
|
+
|
14
|
+
if env[:opsworks].client.stack.berks_enabled?
|
15
|
+
ENV['BERKSHELF_PATH'] = env[:opsworks].data_directory.join('berkshelf').to_s
|
16
|
+
env[:machine].config.berkshelf.enabled = true
|
17
|
+
env[:machine].config.berkshelf.berksfile_path = env[:opsworks].data_directory.join('cookbooks/custom/Berksfile').to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpsWorks
|
3
|
+
module Action
|
4
|
+
class ConfigureChef
|
5
|
+
require_relative '../util/env_helpers'
|
6
|
+
include VagrantPlugins::OpsWorks::Util::EnvHelpers
|
7
|
+
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
return @app.call(env) unless enabled?(env)
|
14
|
+
|
15
|
+
if chef_solo?(env)
|
16
|
+
provisioners(:chef_solo, env).each do |provisioner|
|
17
|
+
provisioner.config.cookbooks_path << [:host, env[:opsworks].data_directory.join('cookbooks/merged').to_s]
|
18
|
+
provisioner.config.roles_path << [:host, env[:opsworks].data_directory.join('roles').to_s]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
@app.call(env)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpsWorks
|
3
|
+
module Action
|
4
|
+
class CreateRoles
|
5
|
+
include VagrantPlugins::OpsWorks::Util::EnvHelpers
|
6
|
+
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
return @app.call(env) unless enabled?(env)
|
13
|
+
|
14
|
+
setup_role_directory(env[:opsworks])
|
15
|
+
|
16
|
+
env[:machine].env.hook(:opsworks_create_roles, runner: ::Vagrant::Action::Runner.new(env: env))
|
17
|
+
|
18
|
+
require 'pp'
|
19
|
+
roles = {}
|
20
|
+
env[:opsworks].client.layers.each do |l|
|
21
|
+
next if opsworks_config(env).ignore_layers.include?(l['name'])
|
22
|
+
roles[l['name']] = {
|
23
|
+
'name' => l['name'],
|
24
|
+
'description' => l['description'],
|
25
|
+
'default_attributes' => {
|
26
|
+
'opsworks' => {
|
27
|
+
'layers' => {
|
28
|
+
l['name'] => {
|
29
|
+
'instances' => {}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
},
|
34
|
+
'run_list' => Hash[Array.new.tap { |a|
|
35
|
+
l['default_recipes'].each{ |k,v|
|
36
|
+
a << [k, v.concat(l['custom_recipes'][k])]
|
37
|
+
}
|
38
|
+
}].select{ |k,v|
|
39
|
+
%w(setup configure deploy).any?{ |s|
|
40
|
+
k.to_s == s
|
41
|
+
}
|
42
|
+
}.values.flatten.select{ |r|
|
43
|
+
!opsworks_config(env).ignore_recipes.include?(r)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
roles.each do |role,data|
|
49
|
+
data[:chef_type] = 'role'
|
50
|
+
data[:json_class] = 'Chef::Role'
|
51
|
+
env[:opsworks].data_directory.join('roles').join("#{role}.json").tap{|p|
|
52
|
+
File.open(p, 'w') {|f| f.puts JSON.pretty_generate(JSON.parse(data.to_json)) }
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
@app.call(env)
|
57
|
+
end
|
58
|
+
|
59
|
+
protected
|
60
|
+
|
61
|
+
def setup_role_directory(opsworks)
|
62
|
+
opsworks.data_directory.join('roles').tap{|d|
|
63
|
+
FileUtils.mkdir_p(d) unless d.file?
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpsWorks
|
3
|
+
module Action
|
4
|
+
class InjectBoxes
|
5
|
+
include VagrantPlugins::OpsWorks::Util::EnvHelpers
|
6
|
+
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
return @app.call(env) unless enabled?(env)
|
13
|
+
|
14
|
+
require_relative '../loader'
|
15
|
+
require_relative '../util/configuration_builder'
|
16
|
+
|
17
|
+
sources = [find_vagrantfile(env[:env])]
|
18
|
+
|
19
|
+
config, _ = env[:env].config_loader.load([:home,:root])
|
20
|
+
builder = VagrantPlugins::OpsWorks::Util::ConfigurationBuilder.new(config.opsworks).tap{ |b|
|
21
|
+
b.use VagrantPlugins::OpsWorks::Loader::Client
|
22
|
+
b.use VagrantPlugins::OpsWorks::Loader::Stack
|
23
|
+
b.use VagrantPlugins::OpsWorks::Loader::Instances
|
24
|
+
}
|
25
|
+
|
26
|
+
sources << ['2', builder]
|
27
|
+
|
28
|
+
env[:env].config_loader.set(:root, sources)
|
29
|
+
|
30
|
+
@app.call(env)
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def find_vagrantfile(environment)
|
36
|
+
[* environment.vagrantfile_name || ['Vagrantfile', 'vagrantfile'] ].map{|f|
|
37
|
+
environment.root_path.join(f) if environment.root_path.join(f).file?
|
38
|
+
}.compact.first
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpsWorks
|
3
|
+
module Action
|
4
|
+
class MergeCookbooks
|
5
|
+
include VagrantPlugins::OpsWorks::Util::EnvHelpers
|
6
|
+
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
return @app.call(env) unless enabled?(env)
|
13
|
+
|
14
|
+
cookbook_path = env[:opsworks].data_directory.join('cookbooks').tap{|d| FileUtils.mkdir_p(d.join('merged')) unless d.join('merged').file? }
|
15
|
+
|
16
|
+
FileUtils.cp_r cookbook_path.join('opsworks/.').to_s, cookbook_path.join('merged').to_s, :remove_destination => true
|
17
|
+
FileUtils.cp_r env[:berkshelf].shelf + '/.', cookbook_path.join('merged').to_s, :remove_destination => true if env[:berkshelf].shelf
|
18
|
+
FileUtils.cp_r cookbook_path.join('custom/.').to_s, cookbook_path.join('merged').to_s, :remove_destination => true if env[:opsworks].client.stack.use_custom_cookbooks?
|
19
|
+
FileUtils.rm_r cookbook_path.join('merged/.git').to_s
|
20
|
+
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpsWorks
|
3
|
+
module Action
|
4
|
+
class SetupEnvironment
|
5
|
+
require_relative '../util/env_helpers'
|
6
|
+
include VagrantPlugins::OpsWorks::Util::EnvHelpers
|
7
|
+
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
return @app.call(env) unless enabled?(env)
|
14
|
+
|
15
|
+
env[:opsworks].data_directory = setup_data_directory
|
16
|
+
|
17
|
+
require_relative '../client'
|
18
|
+
env[:opsworks].client = VagrantPlugins::OpsWorks::Client.new(stack_id(env))
|
19
|
+
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def setup_data_directory
|
26
|
+
Vagrant.user_data_path.join('opsworks').tap{|d|
|
27
|
+
FileUtils.mkdir_p(d.join('cache')) unless d.join('cache').file?
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OpsWorks
|
3
|
+
module Action
|
4
|
+
require_relative 'util/env_helpers'
|
5
|
+
require_relative 'env'
|
6
|
+
require_relative 'action/checkout_cookbooks'
|
7
|
+
require_relative 'action/configure_berks'
|
8
|
+
require_relative 'action/configure_chef'
|
9
|
+
require_relative 'action/create_roles'
|
10
|
+
require_relative 'action/inject_boxes'
|
11
|
+
require_relative 'action/merge_cookbooks'
|
12
|
+
require_relative 'action/setup_environment'
|
13
|
+
class << self
|
14
|
+
def prepare_environment
|
15
|
+
@prepare_environment ||= environment_builder.tap do |b|
|
16
|
+
b.use VagrantPlugins::OpsWorks::Action::InjectBoxes
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@setup ||= environment_builder.tap do |b|
|
22
|
+
b.use VagrantPlugins::OpsWorks::Action::CreateRoles
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def configure_berks
|
27
|
+
@configure_berks ||= environment_builder.tap do |b|
|
28
|
+
b.use VagrantPlugins::OpsWorks::Action::ConfigureBerks
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def configure_chef
|
33
|
+
@configure_chef ||= environment_builder.tap do |b|
|
34
|
+
b.use VagrantPlugins::OpsWorks::Action::ConfigureChef
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def environment_builder
|
41
|
+
::Vagrant::Action::Builder.new.tap do |b|
|
42
|
+
b.use ::Vagrant::Action::Builtin::EnvSet, opsworks: VagrantPlugins::OpsWorks::Env.new
|
43
|
+
b.use VagrantPlugins::OpsWorks::Action::SetupEnvironment
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'vagrant/util/hash_with_indifferent_access'
|
2
|
+
|
3
|
+
module VagrantPlugins::OpsWorks
|
4
|
+
class Application < ::Vagrant::Util::HashWithIndifferentAccess
|
5
|
+
class << self
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def set_or_return(key, value)
|
12
|
+
if value.nil?
|
13
|
+
return self[key]
|
14
|
+
else
|
15
|
+
self[key] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Proxy
|
20
|
+
def method_missing(m, *args, &block)
|
21
|
+
self
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module VagrantPlugins::OpsWorks
|
2
|
+
class Client
|
3
|
+
class App < VagrantPlugins::OpsWorks::Util::DummyConfiguration
|
4
|
+
|
5
|
+
def shortname(value=nil)
|
6
|
+
set_or_return(:name, value)
|
7
|
+
end
|
8
|
+
|
9
|
+
def name(value=nil)
|
10
|
+
set_or_return(:description, value)
|
11
|
+
end
|
12
|
+
|
13
|
+
def data_sources(value=nil)
|
14
|
+
set_or_return(:data_sources, value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def type(value=nil)
|
18
|
+
set_or_return(:type, value)
|
19
|
+
end
|
20
|
+
|
21
|
+
def app_source(value=nil)
|
22
|
+
set_or_return(:app_source, value)
|
23
|
+
end
|
24
|
+
|
25
|
+
def domains(value=nil)
|
26
|
+
set_or_return(:domains, value)
|
27
|
+
end
|
28
|
+
|
29
|
+
def enable_ssl(value=nil)
|
30
|
+
set_or_return(:enable_ssl, value)
|
31
|
+
end
|
32
|
+
|
33
|
+
def ssl_configurations(value=nil)
|
34
|
+
set_or_return(:ssl_configurations, value)
|
35
|
+
end
|
36
|
+
|
37
|
+
def attributes(value=nil)
|
38
|
+
set_or_return(:attributes, value)
|
39
|
+
end
|
40
|
+
|
41
|
+
def environment(value=nil)
|
42
|
+
unless value.nil?
|
43
|
+
value = value.select{|v| !v[:secure]}
|
44
|
+
end
|
45
|
+
set_or_return(:environment, value)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module VagrantPlugins::OpsWorks
|
2
|
+
class Client
|
3
|
+
class Instance < VagrantPlugins::OpsWorks::Util::DummyConfiguration
|
4
|
+
|
5
|
+
def hostname(value=nil)
|
6
|
+
set_or_return(:hostname, value)
|
7
|
+
end
|
8
|
+
|
9
|
+
def layer_ids(value=nil)
|
10
|
+
set_or_return(:layer_ids, value)
|
11
|
+
end
|
12
|
+
|
13
|
+
def os(value=nil)
|
14
|
+
set_or_return(:os, value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def architecture(value=nil)
|
18
|
+
set_or_return(:architecture, value)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|