jamie-vagrant 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jamie-vagrant.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rake'
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Author:: Fletcher Nichol (<fnichol@nichol.ca>)
2
+
3
+ Copyright (C) 2012, Fletcher Nichol
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -0,0 +1,32 @@
1
+ # Jamie::Vagrant
2
+
3
+ [![Build Status](https://secure.travis-ci.org/jamie-ci/jamie-vagrant.png)](https://travis-ci.org/jamie-ci/jamie-vagrant)
4
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/jamie-ci/jamie-vagrant)
5
+
6
+ TODO: Write a gem description
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'jamie-vagrant'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install jamie-vagrant
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+ require 'cane/rake_task'
3
+ require 'tailor/rake_task'
4
+
5
+ desc "Run cane to check quality metrics"
6
+ Cane::RakeTask.new do |cane|
7
+ cane.abc_exclude = %w(
8
+ Jamie::Vagrant.define_vagrant_vm
9
+ )
10
+ end
11
+
12
+ Tailor::RakeTask.new
13
+
14
+ task :default => [ :cane, :tailor ]
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jamie/driver/vagrant_version.rb'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "jamie-vagrant"
8
+ gem.version = Jamie::Driver::VAGRANT_VERSION
9
+ gem.authors = ["Fletcher Nichol"]
10
+ gem.email = ["fnichol@nichol.ca"]
11
+ gem.description = "Jamie::Driver::Vagrant - A Vagrant Driver for Jamie."
12
+ gem.summary = gem.description
13
+ gem.homepage = "https://github.com/jamie-ci/jamie-vagrant/"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = []
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'jamie'
21
+ gem.add_dependency 'vagrant', '~> 1.0.5'
22
+
23
+ gem.add_development_dependency 'cane'
24
+ gem.add_development_dependency 'tailor'
25
+ end
@@ -0,0 +1,78 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
+ #
5
+ # Copyright (C) 2012, Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require 'jamie'
20
+
21
+ module Jamie
22
+
23
+ module Driver
24
+
25
+ # Vagrant driver for Jamie. It communicates to Vagrant via the CLI.
26
+ class Vagrant < Jamie::Driver::SSHBase
27
+
28
+ default_config 'memory', '256'
29
+
30
+ def perform_create(instance, state)
31
+ state['name'] = instance.name
32
+ run_command "vagrant up #{state['name']} --no-provision"
33
+ end
34
+
35
+ def perform_converge(instance, state)
36
+ run_command "vagrant provision #{state['name']}"
37
+ end
38
+
39
+ def perform_destroy(instance, state)
40
+ run_command "vagrant destroy #{state['name']} -f"
41
+ state.delete('name')
42
+ end
43
+
44
+ protected
45
+
46
+ def load_state(instance)
47
+ vagrantfile = File.join(config['jamie_root'], "Vagrantfile")
48
+ create_vagrantfile(vagrantfile) unless File.exists?(vagrantfile)
49
+ super
50
+ end
51
+
52
+ def generate_ssh_args(state)
53
+ Array(state['name'])
54
+ end
55
+
56
+ def ssh(ssh_args, cmd)
57
+ run_command %{vagrant ssh #{ssh_args.first} --command '#{cmd}'}
58
+ end
59
+
60
+ def create_vagrantfile(vagrantfile)
61
+ File.open(vagrantfile, "wb") { |f| f.write(vagrantfile_contents) }
62
+ end
63
+
64
+ def vagrantfile_contents
65
+ arr = []
66
+ arr << %{require 'jamie/vagrant'}
67
+ if File.exists?(File.join(config['jamie_root'], "Berksfile"))
68
+ arr << %{require 'berkshelf/vagrant'}
69
+ end
70
+ arr << %{}
71
+ arr << %{Vagrant::Config.run do |config|}
72
+ arr << %{ Jamie::Vagrant.define_vms(config)}
73
+ arr << %{end\n}
74
+ arr.join("\n")
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
+ #
5
+ # Copyright (C) 2012, Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ module Jamie
20
+
21
+ module Driver
22
+
23
+ # Version string for Vagrant Jamie driver
24
+ VAGRANT_VERSION = "0.1.0"
25
+ end
26
+ end
@@ -0,0 +1,74 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
+ #
5
+ # Copyright (C) 2012, Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require 'forwardable'
20
+ require 'vagrant'
21
+
22
+ require 'jamie'
23
+
24
+ module Jamie
25
+
26
+ module Vagrant
27
+
28
+ # A Vagrant confiuration class which wraps a Jamie::Config instance.
29
+ class Config < ::Vagrant::Config::Base
30
+ extend Forwardable
31
+
32
+ def_delegators :@config, :suites, :suites=, :platforms, :platforms=,
33
+ :instances, :yaml_file, :yaml_file=, :log_level, :log_level=,
34
+ :test_base_path, :test_base_path=, :yaml_data
35
+
36
+ def initialize
37
+ @config = Jamie::Config.new
38
+ @config.yaml_file = ENV['JAMIE_YAML'] if ENV['JAMIE_YAML']
39
+ end
40
+ end
41
+
42
+ # Defines all Vagrant virtual machines, one for each instance.
43
+ #
44
+ # @param config [Vagrant::Config::Top] Vagrant top level config object
45
+ def self.define_vms(config)
46
+ config.jamie.instances.each do |instance|
47
+ define_vagrant_vm(config, instance)
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def self.define_vagrant_vm(config, instance)
54
+ driver = instance.platform.driver
55
+
56
+ config.vm.define instance.name do |c|
57
+ c.vm.box = driver['box']
58
+ c.vm.box_url = driver['box_url'] if driver['box_url']
59
+ c.vm.host_name = "#{instance.name}.vagrantup.com"
60
+ c.vm.customize ["modifyvm", :id, "--memory", driver['memory']]
61
+
62
+ c.vm.provision :chef_solo do |chef|
63
+ chef.log_level = config.jamie.log_level
64
+ chef.run_list = instance.run_list
65
+ chef.json = instance.attributes
66
+ chef.data_bags_path = instance.suite.data_bags_path
67
+ chef.roles_path = instance.suite.roles_path
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ Vagrant.config_keys.register(:jamie) { Jamie::Vagrant::Config }
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jamie-vagrant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fletcher Nichol
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jamie
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: vagrant
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.5
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.5
46
+ - !ruby/object:Gem::Dependency
47
+ name: cane
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: tailor
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Jamie::Driver::Vagrant - A Vagrant Driver for Jamie.
79
+ email:
80
+ - fnichol@nichol.ca
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .travis.yml
87
+ - Gemfile
88
+ - LICENSE
89
+ - README.md
90
+ - Rakefile
91
+ - jamie-vagrant.gemspec
92
+ - lib/jamie/driver/vagrant.rb
93
+ - lib/jamie/driver/vagrant_version.rb
94
+ - lib/jamie/vagrant.rb
95
+ homepage: https://github.com/jamie-ci/jamie-vagrant/
96
+ licenses: []
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ segments:
108
+ - 0
109
+ hash: -634438834892185161
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ segments:
117
+ - 0
118
+ hash: -634438834892185161
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 1.8.24
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Jamie::Driver::Vagrant - A Vagrant Driver for Jamie.
125
+ test_files: []