vagrant-masonry 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.yardopts +6 -0
  4. data/CHANGELOG +190 -0
  5. data/Gemfile +16 -0
  6. data/LICENSE +15 -0
  7. data/README.md +129 -0
  8. data/docs/GettingStarted.markdown +175 -0
  9. data/examples/Vagrantfile +1 -0
  10. data/examples/roles.yaml +29 -0
  11. data/examples/vms.yaml +12 -0
  12. data/lib/config_builder.rb +24 -0
  13. data/lib/config_builder/action/load_extensions.rb +14 -0
  14. data/lib/config_builder/class_registry.rb +72 -0
  15. data/lib/config_builder/extension_handler.rb +22 -0
  16. data/lib/config_builder/filter.rb +6 -0
  17. data/lib/config_builder/filter/boxes.rb +22 -0
  18. data/lib/config_builder/filter/roles.rb +149 -0
  19. data/lib/config_builder/filter_stack.rb +37 -0
  20. data/lib/config_builder/loader.rb +23 -0
  21. data/lib/config_builder/loader/yaml.rb +44 -0
  22. data/lib/config_builder/loader/yaml_erb.rb +24 -0
  23. data/lib/config_builder/model.rb +67 -0
  24. data/lib/config_builder/model/base.rb +101 -0
  25. data/lib/config_builder/model/network/forwarded_port.rb +37 -0
  26. data/lib/config_builder/model/network/private_network.rb +15 -0
  27. data/lib/config_builder/model/provider/azure.rb +66 -0
  28. data/lib/config_builder/model/provider/libvirt.rb +108 -0
  29. data/lib/config_builder/model/provider/virtualbox.rb +35 -0
  30. data/lib/config_builder/model/provider/vmware.rb +40 -0
  31. data/lib/config_builder/model/provider/vmware_fusion.rb +8 -0
  32. data/lib/config_builder/model/provider/vmware_workstation.rb +8 -0
  33. data/lib/config_builder/model/provider/vsphere.rb +30 -0
  34. data/lib/config_builder/model/provisioner/file.rb +24 -0
  35. data/lib/config_builder/model/provisioner/puppet.rb +37 -0
  36. data/lib/config_builder/model/provisioner/puppet_server.rb +27 -0
  37. data/lib/config_builder/model/provisioner/shell.rb +27 -0
  38. data/lib/config_builder/model/root.rb +69 -0
  39. data/lib/config_builder/model/ssh.rb +110 -0
  40. data/lib/config_builder/model/synced_folder.rb +43 -0
  41. data/lib/config_builder/model/vm.rb +235 -0
  42. data/lib/config_builder/model/winrm.rb +56 -0
  43. data/lib/config_builder/model_delegator.rb +30 -0
  44. data/lib/config_builder/plugin.rb +15 -0
  45. data/lib/config_builder/runner.rb +33 -0
  46. data/lib/config_builder/version.rb +3 -0
  47. data/lib/vagrant-masonry.rb +1 -0
  48. data/spec/config_builder/filter/boxes_spec.rb +87 -0
  49. data/spec/config_builder/filter/roles_spec.rb +287 -0
  50. data/spec/config_builder/loader/yaml_spec.rb +76 -0
  51. data/spec/config_builder/model/provider/vmware_fusion_spec.rb +29 -0
  52. data/spec/spec_helper.rb +4 -0
  53. data/templates/locales/en.yml +11 -0
  54. data/vagrant-masonry.gemspec +24 -0
  55. metadata +128 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f70083dc0e5b9557ca2f5ac0c69396d563dd1940
4
+ data.tar.gz: 0b1a113f963a73d8aef8f6f94b8b8f4ecc72928d
5
+ SHA512:
6
+ metadata.gz: 2b6d2d39c277264a06e50cf8e96689fc87054c6c698fd2b250f42d2cf94b8b86e7ca6ab2a4cecc16a471332c039e58ee92d530015a52f9e7f791ee708bd717d0
7
+ data.tar.gz: e1c6fcdf439e40b332b430d668bf27b10124ec05901e02792119cda062da2c7b2680750462b1f781600fd2e40de2e9e5dd5f32ad76dae368c7318bd7ff96e2e5
@@ -0,0 +1,3 @@
1
+ .bundle
2
+ .yardoc
3
+ doc
@@ -0,0 +1,6 @@
1
+ --markup markdown
2
+ -
3
+ README.md
4
+ docs/GettingStarted.markdown
5
+ CHANGELOG
6
+ LICENSE
@@ -0,0 +1,190 @@
1
+ CHANGELOG
2
+ =========
3
+
4
+ 0.13.0
5
+ ------
6
+
7
+ 2014-11-23
8
+
9
+ New feature:
10
+
11
+ * Added support for Vagrant Azure provider
12
+
13
+ 0.12.0
14
+ ------
15
+
16
+ 2014-10-07
17
+
18
+ This is a backwards feature release.
19
+
20
+ * (GH-22) Support for VMware Workstation providers.
21
+
22
+ * (GH-24) New YAML loader which pre-processes data using ERB to enable
23
+ dynamic interpolation of values.
24
+
25
+ * (GH-25) Support for VMware vSphere providers.
26
+
27
+ * (GH-28) Support for libvirt providers.
28
+
29
+ * Support for the file provisioner.
30
+
31
+ Thanks to Nan Liu and Lukas Stanek for their contributions to this release.
32
+
33
+ 0.11.0
34
+ ------
35
+
36
+ 2014-09-17
37
+
38
+ This is a backwards feature release.
39
+
40
+ * (GH-23) Fix misspelling of `disabled` option for synced folders.
41
+
42
+ * (GH-26) Enable configuration of global WinRM options.
43
+
44
+ * Enable configuration of global SSH options.
45
+
46
+ * Enable configuration of additional box download options such as
47
+ checksumming and versioning.
48
+
49
+ Thanks to Nan Liu and Ethan Brown for their contributions to this release.
50
+
51
+ 0.10.1
52
+ ------
53
+
54
+ 2014-07-08
55
+
56
+ This is a backwards bugfix release.
57
+
58
+ * Fixed an issue where VM definitions would end up with linked copies of an
59
+ array because cloning was not used.
60
+
61
+ * The `id` attribute can now be specified for `forwarded_port`.
62
+
63
+ 0.10.0
64
+ ------
65
+
66
+ 2014-05-22
67
+
68
+ This is a backwards compatible feature release.
69
+
70
+ * (GH-20) Add `communicator` to the VM model. This supports Windows machines
71
+ running under Vagrant 1.6.
72
+
73
+ 0.9.0
74
+ -----
75
+
76
+ 2014-05-21
77
+
78
+ This is a backwards compatible feature release.
79
+
80
+ * (GH-19) Multiple providers can be configured by specifying an array of
81
+ options.
82
+
83
+ 0.8.0
84
+ -----
85
+
86
+ 2014-05-02
87
+
88
+ * (GH-16) Add vmware_fusion provider implementation.
89
+
90
+ 0.7.1
91
+ -----
92
+
93
+ 2014-04-22
94
+
95
+ * (GH-17) Call DeepMerge directly to avoid shadowing during loading
96
+
97
+ ### Thanks
98
+
99
+ Thanks to Charlie Sharpsteen creating this release.
100
+
101
+ 0.7.0
102
+ -----
103
+
104
+ 2014-03-19
105
+
106
+ This is a backwards compatible feature release.
107
+
108
+ * (GH-15) Deep merge data when loading configurations. This allows
109
+ individual top level keys to be split up between files.
110
+
111
+ Thanks to Charlie Sharpsteen creating this release.
112
+
113
+ 0.6.0
114
+ -----
115
+
116
+ 2013-10-17
117
+
118
+ This is a backwards incompatible feature release.
119
+
120
+ * Loader::YAML#yamldir can now accept a list of directories to use for
121
+ configuration.
122
+
123
+ Thanks to Charlie Sharpsteen for his help on this release.
124
+
125
+ 0.5.0
126
+ -----
127
+
128
+ 2013-09-18
129
+
130
+ This is a backwards compatible feature release.
131
+
132
+ * (GH-12) Add vm 'guest' platform parameter
133
+
134
+ 0.4.0
135
+ -----
136
+
137
+ 2013-08-28
138
+
139
+ This is a backwards compatible feature release.
140
+
141
+ * (GH-11) Register puppet and puppet_server as provisioners
142
+
143
+ 0.3.1
144
+ -----
145
+
146
+ This is a backwards compatible bugfix release.
147
+
148
+ * Fixed the whole missing variable for ClassRegistry::DuplicateEntry.
149
+ This time, for realsies.
150
+
151
+ 0.3.0
152
+ -----
153
+
154
+ This is a backwards compatible bugfix and feature release
155
+
156
+ ### User notes
157
+
158
+ #### Enhancements
159
+
160
+ * (GH-6) New filter: `boxes`
161
+ * box_url is now a supported vm attribute
162
+
163
+ #### Bugfixes
164
+
165
+ * Better error handling when no configuration is set
166
+ * Add missing variable when raising ClassRegistry::DuplicateEntry error
167
+
168
+ 0.2.0
169
+ -----
170
+
171
+ 2013-08-16
172
+
173
+ This is a backwards compatible bugfix and feature release.
174
+
175
+ ### User notes
176
+
177
+ #### Enhancements
178
+
179
+ * (GH-10) Add support to vm model for hostname.
180
+
181
+ #### Bugfixes
182
+
183
+ * (GH-9) Correctly merge VM attributes by concatentating arrays.
184
+
185
+ 0.1.0
186
+ -----
187
+
188
+ 2013-08-08
189
+
190
+ Initial release.
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
10
+ gem "yard"
11
+ gem "redcarpet"
12
+ end
13
+
14
+ if File.exists? "#{__FILE__}.local"
15
+ eval(File.read("#{__FILE__}.local"), binding)
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Copyright 2013 Adrien Thebo (vagrant-config_builder)
2
+ Copyright 2014 Jozef Izso (vagrant-masonry)
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
@@ -0,0 +1,129 @@
1
+ Vagrant Masonry - Config Builder
2
+ ======================
3
+
4
+ Configure and manage your Vagrant environments using structured data.
5
+
6
+ > Masonry is the craft of shaping rough pieces of rock into accurate geometrical shapes, at times simple, but some of considerable complexity, and then arranging the resulting stones to form structures.
7
+
8
+ Synopsis
9
+ --------
10
+
11
+ This plugin provides an interface to the Vagrant configuration constructs in a
12
+ logic free manner. You can format your input data to fit your needs and use
13
+ `vagrant-masonry` to transform that into the needed Vagrant config.
14
+
15
+ Example
16
+ -------
17
+
18
+ This example loads all yaml files in the config directory and generates a
19
+ Vagrant config based on that information. File names are arbitrary and chosen
20
+ for clarity.
21
+
22
+ #### Directory structure
23
+
24
+ ```shell
25
+ .
26
+ ├── config
27
+ │   ├── roles.yaml
28
+ │   └── vms.yaml
29
+ └── Vagrantfile
30
+ ```
31
+
32
+ #### Vagrantfile
33
+
34
+ For pure yaml configurations, use yaml loader:
35
+ ```ruby
36
+ require 'masonry'
37
+ Vagrant.configure('2', &ConfigBuilder.load(
38
+ :yaml,
39
+ :yamldir,
40
+ File.expand_path('../config', __FILE__)
41
+ ))
42
+ ```
43
+
44
+ For yaml erb configurations, use yaml_erb loader:
45
+ ```ruby
46
+ require 'masonry'
47
+ Vagrant.configure('2', &ConfigBuilder.load(
48
+ :yaml_erb,
49
+ :yamldir,
50
+ File.expand_path('../config', __FILE__)
51
+ ))
52
+ ```
53
+
54
+ The yaml_erb loader would allow configuration such as:
55
+ ```yaml
56
+ ---
57
+ roles:
58
+ puppet_apply:
59
+ provisioners:
60
+ - type: puppet
61
+ manifests_path: 'tests'
62
+ module_path: 'spec/fixtures/modules'
63
+ manifest_file: <%= ENV['VAGRANT_MANIFEST'] || 'init.pp' %>
64
+ ```
65
+
66
+ #### config/roles.yaml
67
+
68
+ ```yaml
69
+ ---
70
+ boxes:
71
+ centos-65-x64: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-puppet.box
72
+ debian-73-x64: http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-puppet.box
73
+ roles:
74
+ bigvm:
75
+ provider:
76
+ type: virtualbox
77
+ customize: [[modifyvm, !ruby/sym id, '--memory', 1024]]
78
+ synced_folders:
79
+ - host_path: '.'
80
+ guest_path: '/vagrant'
81
+ disabled: true
82
+ smallvm:
83
+ provider:
84
+ type: vmware
85
+ vmx:
86
+ memsize: 512
87
+ numvcpus: 1
88
+ ```
89
+
90
+ #### config/vms.yaml
91
+
92
+ ```yaml
93
+ ---
94
+ vms:
95
+ -
96
+ name: db
97
+ private_networks: [ {ip: '10.20.1.2'} ]
98
+ box: centos-65-x64
99
+ hostname: db.puppetlabs.vm
100
+ roles: bigvm
101
+ -
102
+ name: web
103
+ private_networks: [ {ip: '10.20.1.3'} ]
104
+ box: debian-73-x64
105
+ ```
106
+
107
+ Installation
108
+ ------------
109
+
110
+ ### Installation into the Vagrant internal gems:
111
+
112
+ * `vagrant plugin install vagrant-masonry`
113
+
114
+ ### Installation from source
115
+
116
+ Build the gem:
117
+
118
+ * `gem build vagrant-masonry.gemspec`
119
+
120
+ Install the gem:
121
+
122
+ * `gem install vagrant-masonry-<version>.gem`
123
+
124
+ License
125
+ -------
126
+
127
+ **Vagrant Masonry** plugin is based on [vagrant-config_builder](https://github.com/adrienthebo/vagrant-config_builder) plugin.
128
+
129
+ **Vagrant Masonry** is licensed under [Apache 2.0](LICENSE) license.
@@ -0,0 +1,175 @@
1
+ # @title Getting Started
2
+
3
+ # Getting Started
4
+
5
+ The vagrant-config_builder plugin is designed to ease the management of complex Vagrant setups.
6
+ This goal is accomplished by moving configuration data out of the Vagrant DSL and into formats that excel at expressing hierarchical information.
7
+ Moving the configuration to a dedicated data structure allows multiple VMs to be defined by composing and remixing a set of common components.
8
+ This guide describes:
9
+
10
+ - How to transition a Vagrant configuration to a ConfigBuilder data structure.
11
+
12
+ - How vagrant-config_builder maps that structure back to a Vagrant configuration.
13
+
14
+ - The methodology that vagrant-config_builder uses to manage components of configuration shared by multiple VMs.
15
+
16
+
17
+ ## Expressing Configuration as Data
18
+
19
+ This guide will walk through re-implementing the following Vagrantfile using vagrant-config_builder:
20
+
21
+ ```ruby
22
+ # Vagrantfile
23
+
24
+ # Requires the following plugins:
25
+ #
26
+ # - vagrant-hosts
27
+ # - vagrant-auto_network
28
+ #
29
+ Vagrant.configure('2') do |config|
30
+
31
+ box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box'
32
+ box_name = 'centos-64-x64-vbox4210-nocm'
33
+
34
+ config.vm.define :puppetmaster do |node|
35
+ node.vm.box_url = box_url
36
+ node.vm.box = box_name
37
+
38
+ node.vm.hostname = 'puppetmaster.boxnet'
39
+
40
+ node.vm.network :private_network, :ip => '0.0.0.0', :auto_network => true
41
+ node.vm.provision :hosts
42
+
43
+ node.vm.provision :shell, :inline => <<-EOF
44
+ if which puppet > /dev/null 2>&1; then
45
+ echo 'Puppet Installed.'
46
+ else
47
+ echo 'Installing Puppet Master.'
48
+ rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
49
+ yum --nogpgcheck -y install puppet-server
50
+ echo '*.boxnet' > /etc/puppet/autosign.conf
51
+ /usr/bin/puppet resource service iptables ensure=stopped enable=false
52
+ /usr/bin/puppet resource service puppetmaster ensure=running enable=true
53
+ fi
54
+ EOF
55
+ end
56
+
57
+ config.vm.define :puppetagent do |node|
58
+ node.vm.box_url = box_url
59
+ node.vm.box = box_name
60
+
61
+ node.vm.hostname = 'puppetagent.boxnet'
62
+
63
+ node.vm.network :private_network, :ip => '0.0.0.0', :auto_network => true
64
+ node.vm.provision :hosts
65
+
66
+ node.vm.provision :shell, :inline => <<-EOF
67
+ if which puppet > /dev/null 2>&1; then
68
+ echo 'Puppet Installed.'
69
+ else
70
+ echo 'Installing Puppet Agent.'
71
+ rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
72
+ yum --nogpgcheck -y install puppet
73
+ fi
74
+ EOF
75
+ end
76
+
77
+ end
78
+ ```
79
+
80
+ The above listing showcases several examples of duplicated configuration: both VMs are using the same Vagrant box, both are configuring their networks in the same way and both are provisioned using nearly identical shell scripts.
81
+ In fact, the only real difference between the VMs are the hostnames and the few lines of shell that install and configure the Puppet master instead or the Puppet agent.
82
+ These little bits of shared configuration pop up constantly in multi-machine Vagrant environments and are commonly handled by a combination of copy-and-paste and factoring out bits of data and configuration into variables or methods (such as `box_name` and `box_url` used above).
83
+ There are some significant drawbacks to this situation:
84
+
85
+ - Copy and paste quickly becomes expensive to maintain as the number of machines in the environment increases.
86
+
87
+ - Factoring configuration out to variables and methods can help, but requires care to produce something that is portable and reusable across environments.
88
+
89
+ - Determining which bits of configuration are shared among which machines is a challenging task to complete quickly and usually requires a careful reading of the Vagrantfile.
90
+
91
+ vagrant-config_builder approaches this problem by storing every bit of configuration in a unified data structure.
92
+ The structure can be loaded from any data source that is convertable to a hash such as YAML, JSON, XML (possibly [interpretive dance][oscar data sources]).
93
+ Generation of configuration hashes from data sources is implemented through the `ConfigBuilder::Loader` module and is completely pluggable.
94
+ This guide will use YAML as the configuration storage format as vagrant-config_builder includes a YAML Loader.
95
+
96
+ If the Vagrantfile above were to be translated to YAML, it would look like this:
97
+
98
+ ```yaml
99
+ # config/vms.yaml
100
+ ---
101
+ vms:
102
+ - name: puppetmaster
103
+ box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
104
+ box: centos-64-x64-vbox4210-nocm
105
+ hostname: puppetmaster.boxnet
106
+ private_networks:
107
+ - {ip: 0.0.0.0, auto_network: true}
108
+ provisioners:
109
+ - type: hosts
110
+ - type: shell
111
+ inline: |
112
+ if which puppet > /dev/null 2>&1; then
113
+ echo 'Puppet Installed.'
114
+ else
115
+ echo 'Installing Puppet Master.'
116
+ rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
117
+ yum --nogpgcheck -y install puppet-server
118
+ echo '*.boxnet' > /etc/puppet/autosign.conf
119
+ /usr/bin/puppet resource service iptables ensure=stopped enable=false
120
+ /usr/bin/puppet resource service puppetmaster ensure=running enable=true
121
+ fi
122
+
123
+ - name: puppetagent
124
+ box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
125
+ box: centos-64-x64-vbox4210-nocm
126
+ hostname: puppetagent.boxnet
127
+ private_networks:
128
+ - {ip: 0.0.0.0, auto_network: true}
129
+ provisioners:
130
+ - type: hosts
131
+ - type: shell
132
+ inline: |
133
+ if which puppet > /dev/null 2>&1; then
134
+ echo 'Puppet Installed.'
135
+ else
136
+ echo 'Installing Puppet Master.'
137
+ rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
138
+ yum --nogpgcheck -y install puppet
139
+ fi
140
+ ```
141
+ The YAML configuration above maps very closely to the original Vagrant DSL.
142
+ The major differences are:
143
+
144
+ - Repetitive bits of syntax such as `config.vm.*` and `node.vm.*` are now expressed implicitly through the structure of the data.
145
+
146
+ - Operations that are executed multiple times are expressed as arrays. These are:
147
+
148
+ - Defining VMs.
149
+
150
+ - Defining network interfaces on VMs.
151
+
152
+ - Running provisioners on VMs.
153
+
154
+ The mapping between the ConfigBuilder data and the original Vagrantfile will be covered in detail in the next section.
155
+ With the YAML configuration saved in `config/vms.yaml`, the Vagrantfile can updated to invoke `ConfigBuilder.load`:
156
+
157
+ ```ruby
158
+ # Vagrantfile
159
+
160
+ # Requires the following plugins:
161
+ #
162
+ # - vagrant-hosts
163
+ # - vagrant-auto_network
164
+ # - vagrant-config_builder
165
+ #
166
+ Vagrant.configure('2', &ConfigBuilder.load(
167
+ :yaml,
168
+ :yamldir,
169
+ File.expand_path('../config', __FILE__)
170
+ ))
171
+ ```
172
+
173
+ This calls the `yamldir` method of the YAML Loader and passes a path to a `config` directory located adjacent to the Vagrantfile.
174
+
175
+ [oscar data sources]: http://www.youtube.com/watch?v=1TgGQjjLDXg&t=19m27s