vagrant-boxen 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.vimrc +1 -0
  2. data/Puppetfile +9 -0
  3. data/Puppetfile.lock +18 -0
  4. data/README.md +15 -8
  5. data/Rakefile +3 -2
  6. data/Vagrantfile +16 -1
  7. data/lib/vagrant-boxen/base_module.rb +24 -0
  8. data/lib/vagrant-boxen/hash_slice.rb +11 -0
  9. data/lib/vagrant-boxen/manifest_builder.rb +21 -0
  10. data/lib/vagrant-boxen/modules/memcached.rb +24 -0
  11. data/lib/vagrant-boxen/modules/redis.rb +29 -0
  12. data/lib/vagrant-boxen/options_evaluator.rb +23 -0
  13. data/lib/vagrant-boxen/provisioner.rb +32 -13
  14. data/lib/vagrant-boxen/version.rb +1 -1
  15. data/lib/vagrant-boxen.rb +7 -3
  16. data/{puppet/modules → puppet-modules}/README.md +0 -0
  17. data/puppet-modules/gcc/CHANGELOG +3 -0
  18. data/puppet-modules/gcc/LICENSE +201 -0
  19. data/puppet-modules/gcc/Modulefile +10 -0
  20. data/puppet-modules/gcc/manifests/init.pp +21 -0
  21. data/puppet-modules/gcc/manifests/params.pp +23 -0
  22. data/puppet-modules/gcc/metadata.json +25 -0
  23. data/{puppet/modules → puppet-modules}/memcached/.fixtures.yml +0 -0
  24. data/{puppet/modules → puppet-modules}/memcached/.gemfile +0 -0
  25. data/{puppet/modules → puppet-modules}/memcached/LICENSE +0 -0
  26. data/{puppet/modules → puppet-modules}/memcached/Modulefile +0 -0
  27. data/{puppet/modules → puppet-modules}/memcached/README-DEVELOPER +0 -0
  28. data/{puppet/modules → puppet-modules}/memcached/README.md +0 -0
  29. data/{puppet/modules → puppet-modules}/memcached/lib/puppet/parser/functions/memcached_max_memory.rb +0 -0
  30. data/{puppet/modules → puppet-modules}/memcached/manifests/init.pp +0 -0
  31. data/{puppet/modules → puppet-modules}/memcached/manifests/params.pp +0 -0
  32. data/{puppet/modules → puppet-modules}/memcached/templates/memcached.conf.erb +0 -0
  33. data/{puppet/modules → puppet-modules}/memcached/templates/memcached_sysconfig.erb +0 -0
  34. data/puppet-modules/redis/.fixtures.yml +6 -0
  35. data/puppet-modules/redis/.gemfile +7 -0
  36. data/puppet-modules/redis/CHANGES.md +39 -0
  37. data/puppet-modules/redis/Modulefile +7 -0
  38. data/puppet-modules/redis/README.md +44 -0
  39. data/puppet-modules/redis/files/redis-2.4.13.tar.gz +0 -0
  40. data/puppet-modules/redis/files/redis.conf +492 -0
  41. data/puppet-modules/redis/manifests/init.pp +199 -0
  42. data/puppet-modules/redis/templates/redis.init.erb +96 -0
  43. data/puppet-modules/redis/templates/redis_port.conf.erb +412 -0
  44. data/puppet-modules/wget/Modulefile +8 -0
  45. data/puppet-modules/wget/README.md +37 -0
  46. data/puppet-modules/wget/manifests/init.pp +98 -0
  47. data/puppet-modules/wget/metadata.json +27 -0
  48. data/spec/unit/manifest_builder_spec.rb +18 -0
  49. data/spec/unit/modules/memcached_spec.rb +15 -0
  50. data/spec/unit/modules/redis_spec.rb +19 -0
  51. data/spec/unit/provisioner_spec.rb +54 -52
  52. metadata +49 -17
  53. data/lib/vagrant_init.rb +0 -1
@@ -0,0 +1,8 @@
1
+ name 'maestrodev-wget'
2
+ version '1.1.0'
3
+ source 'http://github.com/maestrodev/puppet-wget.git'
4
+ author 'maestrodev'
5
+ license 'Apache License, Version 2.0'
6
+ summary 'Download files with wget'
7
+ description 'A module for wget that allows downloading of files, supporting authentication'
8
+ project_page 'http://github.com/maestrodev/puppet-wget'
@@ -0,0 +1,37 @@
1
+ A Puppet module to download files with wget, supporting authentication.
2
+
3
+ # Example
4
+
5
+ include wget
6
+
7
+ wget::fetch { "download":
8
+ source => "http://www.google.com/index.html",
9
+ destination => "/tmp/index.html",
10
+ timeout => 0,
11
+ verbose => false,
12
+ }
13
+
14
+ wget::authfetch { "download":
15
+ source => "http://www.google.com/index.html",
16
+ destination => "/tmp/index.html",
17
+ user => "user",
18
+ password => "password",
19
+ timeout => 0,
20
+ verbose => false,
21
+ }
22
+
23
+ # License
24
+
25
+ Copyright 2011-2013 MaestroDev
26
+
27
+ Licensed under the Apache License, Version 2.0 (the "License");
28
+ you may not use this file except in compliance with the License.
29
+ You may obtain a copy of the License at
30
+
31
+ http://www.apache.org/licenses/LICENSE-2.0
32
+
33
+ Unless required by applicable law or agreed to in writing, software
34
+ distributed under the License is distributed on an "AS IS" BASIS,
35
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36
+ See the License for the specific language governing permissions and
37
+ limitations under the License.
@@ -0,0 +1,98 @@
1
+ ################################################################################
2
+ # Class: wget
3
+ #
4
+ # This class will install wget - a tool used to download content from the web.
5
+ #
6
+ ################################################################################
7
+ class wget($version='installed') {
8
+
9
+ if $::operatingsystem != 'Darwin' {
10
+ package { "wget": ensure => $version }
11
+ }
12
+ }
13
+
14
+ ################################################################################
15
+ # Definition: wget::fetch
16
+ #
17
+ # This class will download files from the internet. You may define a web proxy
18
+ # using $http_proxy if necessary.
19
+ #
20
+ ################################################################################
21
+ define wget::fetch($source,$destination,$timeout="0",$verbose=false) {
22
+ include wget
23
+ # using "unless" with test instead of "creates" to re-attempt download
24
+ # on empty files.
25
+ # wget creates an empty file when a download fails, and then it wouldn't try
26
+ # again to download the file
27
+ if $::http_proxy {
28
+ $environment = [ "HTTP_PROXY=$::http_proxy", "http_proxy=$::http_proxy" ]
29
+ }
30
+ else {
31
+ $environment = []
32
+ }
33
+
34
+ $verbose_option = $verbose ? {
35
+ true => "--verbose",
36
+ false => "--no-verbose"
37
+ }
38
+
39
+ exec { "wget-$name":
40
+ command => "wget $verbose_option --output-document=$destination $source",
41
+ timeout => $timeout,
42
+ unless => "test -s $destination",
43
+ environment => $environment,
44
+ path => "/usr/bin:/usr/sbin:/bin:/usr/local/bin:/opt/local/bin",
45
+ require => Class[wget],
46
+ }
47
+ }
48
+
49
+ ################################################################################
50
+ # Definition: wget::authfetch
51
+ #
52
+ # This class will download files from the internet. You may define a web proxy
53
+ # using $http_proxy if necessary. Username must be provided. And the user's
54
+ # password must be stored in the password variable within the .wgetrc file.
55
+ #
56
+ ################################################################################
57
+ define wget::authfetch($source,$destination,$user,$password="",$timeout="0",$verbose=false) {
58
+ include wget
59
+ if $http_proxy {
60
+ $environment = [ "HTTP_PROXY=$http_proxy", "http_proxy=$http_proxy", "WGETRC=/tmp/wgetrc-$name" ]
61
+ }
62
+ else {
63
+ $environment = [ "WGETRC=/tmp/wgetrc-$name" ]
64
+ }
65
+
66
+ $verbose_option = $verbose ? {
67
+ true => "--verbose",
68
+ false => "--no-verbose"
69
+ }
70
+
71
+ case $::operatingsystem {
72
+ 'Darwin': {
73
+ # This is to work around an issue with macports wget and out of date CA cert bundle. This requires
74
+ # installing the curl-ca-bundle package like so:
75
+ #
76
+ # sudo port install curl-ca-bundle
77
+ $wgetrc_content = "password=$password\nCA_CERTIFICATE=/opt/local/share/curl/curl-ca-bundle.crt\n"
78
+ }
79
+ default: {
80
+ $wgetrc_content = "password=$password"
81
+ }
82
+ }
83
+
84
+ file { "/tmp/wgetrc-$name":
85
+ owner => root,
86
+ mode => 600,
87
+ content => $wgetrc_content,
88
+ } ->
89
+ exec { "wget-$name":
90
+ command => "wget $verbose_option --user=$user --output-document=$destination $source",
91
+ timeout => $timeout,
92
+ unless => "test -s $destination",
93
+ environment => $environment,
94
+ path => "/usr/bin:/usr/sbin:/bin:/usr/local/bin:/opt/local/bin",
95
+ require => Class[wget],
96
+ }
97
+ }
98
+
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "maestrodev-wget",
3
+ "version": "1.1.0",
4
+ "source": "http://github.com/maestrodev/puppet-wget.git",
5
+ "author": "maestrodev",
6
+ "license": "Apache License, Version 2.0",
7
+ "summary": "Download files with wget",
8
+ "description": "A module for wget that allows downloading of files, supporting authentication",
9
+ "project_page": "http://github.com/maestrodev/puppet-wget",
10
+ "dependencies": [
11
+
12
+ ],
13
+ "types": [
14
+
15
+ ],
16
+ "checksums": {
17
+ "Gemfile": "4867df718b033e152c59c2a418e88b92",
18
+ "Gemfile.lock": "b3e4cf700f055d8d242ad877da298127",
19
+ "Modulefile": "319654cea17d4ad7af5a45f4746f6678",
20
+ "README.md": "53e3a8bdf9ad988aae9b9581831bbcd6",
21
+ "Rakefile": "527f8893f2694a9bc92993074f011cc3",
22
+ "manifests/init.pp": "7a1575c5a0a755b01dcdd2dbf4f8e956",
23
+ "spec/classes/init_spec.rb": "337ce66ffc43c7478ff0d3ff166d278a",
24
+ "spec/fixtures/manifests/site.pp": "627dec82fd1b0d0b4f9e47135ed3e1b7",
25
+ "spec/spec_helper.rb": "0db89c9a486df193c0e40095422e19dc"
26
+ }
27
+ }
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vagrant::Boxen::ManifestBuilder do
4
+ let(:rbenv) { mock(:rbenv_module, :build_manifest => 'RBENV') }
5
+ let(:memcached) { mock(:memcached_module, :build_manifest => 'MEMCACHED') }
6
+ let(:config) { mock(:config, :enabled_modules => [rbenv, memcached]) }
7
+ let(:manifest) { subject.build }
8
+
9
+ subject { described_class.new(config) }
10
+
11
+ it 'builds manifest based on enabled modules' do
12
+ manifest.should =~ /RBENV\s+MEMCACHED/
13
+ end
14
+
15
+ it 'adds default path for Exec resource' do
16
+ manifest.split("\n").first.should =~ /^Exec { path => \[ '\/bin\/'/
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vagrant::Boxen::Modules::Memcached do
4
+ let(:manifest) { subject.build_manifest }
5
+
6
+ subject { described_class.new(:memory => '10%') }
7
+
8
+ it 'includes memcached class on manifest' do
9
+ manifest.should =~ /^class { 'memcached': /
10
+ end
11
+
12
+ it 'maps memory option to max_memory' do
13
+ manifest.should =~ /max_memory\s+=>\s+'10%',/
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vagrant::Boxen::Modules::Redis do
4
+ let(:manifest) { subject.build_manifest }
5
+
6
+ subject { described_class.new(:memory => '1gb', :port => '1234') }
7
+
8
+ it 'includes redis class on manifest' do
9
+ manifest.should =~ /^class { 'redis': /
10
+ end
11
+
12
+ it 'maps memory option to redis_max_memory' do
13
+ manifest.should =~ /redis_max_memory\s+=>\s+'1gb',/
14
+ end
15
+
16
+ it 'maps port option to redis_port' do
17
+ manifest.should =~ /redis_port\s+=>\s+'1234',/
18
+ end
19
+ end
@@ -1,56 +1,58 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Vagrant::Boxen::Provisioner do
4
- let(:uuid) { 'box-uuid' }
5
- let(:config) { described_class::Config.new }
6
- let(:puppet_manifests_path) { "/tmp/vagrant-boxen-#{uuid}" }
7
- let(:puppet_module_path) { File.join(File.expand_path('../../../', __FILE__), 'puppet/modules') }
8
-
9
- before do
10
- @app, @env = action_env(vagrant_env.vms.values.first.env)
11
- @env['vm'].stub(:uuid => uuid)
12
- end
13
-
14
- subject { described_class.new(@env, config) }
15
-
16
- describe 'inner puppet provisioner configuration' do
17
- # REFACTOR: This is way too much coupling
18
- let(:puppet_config) { subject.instance_variable_get(:@puppet_provisioner).config }
19
-
20
- it 'sets module path to vendored puppet modules' do
21
- puppet_config.module_path.should == puppet_module_path
22
- end
23
-
24
- it 'sets the manifest path to the tmp folder' do
25
- puppet_config.manifests_path.should == puppet_manifests_path
26
- end
27
- end
28
-
29
- describe 'provisioner flow' do
30
- let(:puppet) { fire_double('Vagrant::Provisioners::Puppet', :prepare => true, :provision! => true) }
31
- subject { described_class.new(@env, config, puppet) }
32
-
33
- context 'preparation' do
34
- before { subject.prepare }
35
-
36
- it 'generates box manifest on tmp folder based on enabled modules' do
37
- File.read("#{puppet_manifests_path}/site.pp").should_not =~ /memcached/
38
- config.memcached!
39
- subject.prepare
40
- File.read("#{puppet_manifests_path}/site.pp").should =~ /memcached/
41
- end
42
-
43
- it 'delegates to puppet provisioner' do
44
- puppet.should have_received(:prepare)
45
- end
46
- end
47
-
48
- context 'provisioning' do
49
- before { subject.provision! }
50
-
51
- it 'delegates to puppet provisioner' do
52
- puppet.should have_received(:provision!)
53
- end
54
- end
55
- end
4
+ let(:uuid) { 'box-uuid' }
5
+ let(:config) { described_class::Config.new }
6
+ let(:puppet_manifests_path) { "/tmp/vagrant-boxen-#{uuid}" }
7
+ let(:puppet_module_path) { File.join(File.expand_path('../../../', __FILE__), 'puppet-modules') }
8
+
9
+ before do
10
+ @app, @env = action_env(vagrant_env.vms.values.first.env)
11
+ @env['vm'].stub(:uuid => uuid)
12
+ end
13
+
14
+ subject { described_class.new(@env, config) }
15
+
16
+ describe 'inner puppet provisioner configuration' do
17
+ # REFACTOR: This is way too much coupling
18
+ let(:puppet_config) { subject.instance_variable_get(:@puppet_provisioner).config }
19
+
20
+ it 'sets module path to vendored puppet modules' do
21
+ puppet_config.module_path.should == puppet_module_path
22
+ end
23
+
24
+ it 'sets the manifest path to the tmp folder' do
25
+ puppet_config.manifests_path.should == puppet_manifests_path
26
+ end
27
+ end
28
+
29
+ describe 'provisioner flow' do
30
+ let(:puppet) { fire_double('Vagrant::Provisioners::Puppet', :prepare => true, :provision! => true) }
31
+ let(:builder) { fire_double('Vagrant::Boxen::ManifestBuilder', :build => 'PUPPET MANIFEST!') }
32
+
33
+ subject { described_class.new(@env, config, puppet) }
34
+
35
+ context 'preparation' do
36
+ before do
37
+ Vagrant::Boxen::ManifestBuilder.stub(new: builder)
38
+ subject.prepare
39
+ end
40
+
41
+ it 'generates box manifest using the builder' do
42
+ File.read("#{puppet_manifests_path}/site.pp").should == 'PUPPET MANIFEST!'
43
+ end
44
+
45
+ it 'delegates to puppet provisioner' do
46
+ puppet.should have_received(:prepare)
47
+ end
48
+ end
49
+
50
+ context 'provisioning' do
51
+ before { subject.provision! }
52
+
53
+ it 'delegates to puppet provisioner' do
54
+ puppet.should have_received(:provision!)
55
+ end
56
+ end
57
+ end
56
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-boxen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-18 00:00:00.000000000 Z
12
+ date: 2013-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false
@@ -37,6 +37,7 @@ files:
37
37
  - .gitignore
38
38
  - .rspec
39
39
  - .travis.yml
40
+ - .vimrc
40
41
  - Gemfile
41
42
  - Guardfile
42
43
  - LICENSE.txt
@@ -46,22 +47,50 @@ files:
46
47
  - Rakefile
47
48
  - Vagrantfile
48
49
  - lib/vagrant-boxen.rb
50
+ - lib/vagrant-boxen/base_module.rb
51
+ - lib/vagrant-boxen/hash_slice.rb
52
+ - lib/vagrant-boxen/manifest_builder.rb
53
+ - lib/vagrant-boxen/modules/memcached.rb
54
+ - lib/vagrant-boxen/modules/redis.rb
55
+ - lib/vagrant-boxen/options_evaluator.rb
49
56
  - lib/vagrant-boxen/provisioner.rb
50
57
  - lib/vagrant-boxen/version.rb
51
- - lib/vagrant_init.rb
52
- - puppet/modules/README.md
53
- - puppet/modules/memcached/.fixtures.yml
54
- - puppet/modules/memcached/.gemfile
55
- - puppet/modules/memcached/LICENSE
56
- - puppet/modules/memcached/Modulefile
57
- - puppet/modules/memcached/README-DEVELOPER
58
- - puppet/modules/memcached/README.md
59
- - puppet/modules/memcached/lib/puppet/parser/functions/memcached_max_memory.rb
60
- - puppet/modules/memcached/manifests/init.pp
61
- - puppet/modules/memcached/manifests/params.pp
62
- - puppet/modules/memcached/templates/memcached.conf.erb
63
- - puppet/modules/memcached/templates/memcached_sysconfig.erb
58
+ - puppet-modules/README.md
59
+ - puppet-modules/gcc/CHANGELOG
60
+ - puppet-modules/gcc/LICENSE
61
+ - puppet-modules/gcc/Modulefile
62
+ - puppet-modules/gcc/manifests/init.pp
63
+ - puppet-modules/gcc/manifests/params.pp
64
+ - puppet-modules/gcc/metadata.json
65
+ - puppet-modules/memcached/.fixtures.yml
66
+ - puppet-modules/memcached/.gemfile
67
+ - puppet-modules/memcached/LICENSE
68
+ - puppet-modules/memcached/Modulefile
69
+ - puppet-modules/memcached/README-DEVELOPER
70
+ - puppet-modules/memcached/README.md
71
+ - puppet-modules/memcached/lib/puppet/parser/functions/memcached_max_memory.rb
72
+ - puppet-modules/memcached/manifests/init.pp
73
+ - puppet-modules/memcached/manifests/params.pp
74
+ - puppet-modules/memcached/templates/memcached.conf.erb
75
+ - puppet-modules/memcached/templates/memcached_sysconfig.erb
76
+ - puppet-modules/redis/.fixtures.yml
77
+ - puppet-modules/redis/.gemfile
78
+ - puppet-modules/redis/CHANGES.md
79
+ - puppet-modules/redis/Modulefile
80
+ - puppet-modules/redis/README.md
81
+ - puppet-modules/redis/files/redis-2.4.13.tar.gz
82
+ - puppet-modules/redis/files/redis.conf
83
+ - puppet-modules/redis/manifests/init.pp
84
+ - puppet-modules/redis/templates/redis.init.erb
85
+ - puppet-modules/redis/templates/redis_port.conf.erb
86
+ - puppet-modules/wget/Modulefile
87
+ - puppet-modules/wget/README.md
88
+ - puppet-modules/wget/manifests/init.pp
89
+ - puppet-modules/wget/metadata.json
64
90
  - spec/spec_helper.rb
91
+ - spec/unit/manifest_builder_spec.rb
92
+ - spec/unit/modules/memcached_spec.rb
93
+ - spec/unit/modules/redis_spec.rb
65
94
  - spec/unit/provisioner_spec.rb
66
95
  - vagrant-boxen.gemspec
67
96
  homepage: https://github.com/fgrehm/vagrant-boxen
@@ -77,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
106
  version: '0'
78
107
  segments:
79
108
  - 0
80
- hash: -3862497067316697777
109
+ hash: 3320739436277182555
81
110
  none: false
82
111
  required_rubygems_version: !ruby/object:Gem::Requirement
83
112
  requirements:
@@ -86,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
115
  version: '0'
87
116
  segments:
88
117
  - 0
89
- hash: -3862497067316697777
118
+ hash: 3320739436277182555
90
119
  none: false
91
120
  requirements: []
92
121
  rubyforge_project:
@@ -96,4 +125,7 @@ specification_version: 3
96
125
  summary: Easier vagrant development boxes creation
97
126
  test_files:
98
127
  - spec/spec_helper.rb
128
+ - spec/unit/manifest_builder_spec.rb
129
+ - spec/unit/modules/memcached_spec.rb
130
+ - spec/unit/modules/redis_spec.rb
99
131
  - spec/unit/provisioner_spec.rb
data/lib/vagrant_init.rb DELETED
@@ -1 +0,0 @@
1
- require 'vagrant-boxen'