vagrant-saltdeps 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGLOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +22 -15
- data/lib/vagrant-saltdeps/provisioner.rb +19 -13
- data/lib/vagrant-saltdeps/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0224912ef2524714f2f65005c3dea52d0ba4ddd9
|
4
|
+
data.tar.gz: 0d66dc90263a2eab751fdcf8449b7fba904924d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f32691bc9a10e02dedd5bc1da1d762e54627929bacb67d39796a480cfeeafb9cdb927a1c3323b39d97bf489e7b959a42a2622b2c2a40c0e95cb92ab2c61667b1
|
7
|
+
data.tar.gz: 7efc5d4ff757e61ac583c951be659fc75238a3598b85f4b27b736d127d6f64bbf1a740f9f025fed5ef465dd6060d2b6468226748a600b907995b9218af06bba4
|
data/CHANGLOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# vagrant-saltdeps
|
2
2
|
[](https://gitter.im/joshughes/vagrant-saltdeps?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
3
3
|
|
4
|
-
When testing salt formula with vagrant you may have one or many dependent formulas that are required to fully test your new formula. Vagrantsaltdeps is meant to help you manage these dependencies by checking them out from git and making them
|
4
|
+
When testing salt formula with vagrant you may have one or many dependent formulas that are required to fully test your new formula. Vagrantsaltdeps is meant to help you manage these dependencies by checking them out from git and making them available to your vagrant machine.
|
5
5
|
|
6
6
|
**NOTE:** This plugin requires Vagrant 1.2+,
|
7
7
|
|
@@ -14,7 +14,7 @@ When testing salt formula with vagrant you may have one or many dependent formul
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
Install using standard Vagrant 1.1+ plugin installation methods.
|
17
|
+
Install using standard Vagrant 1.1+ plugin installation methods.
|
18
18
|
|
19
19
|
```
|
20
20
|
$ vagrant plugin install vagrant-saltdeps
|
@@ -24,15 +24,22 @@ $ vagrant plugin install vagrant-saltdeps
|
|
24
24
|
|
25
25
|
## Quick Start
|
26
26
|
|
27
|
-
After installing the plugin (instructions above), you must create a saltdeps.yml file somewhere in your repo. This file along with your grains and pillar files must live in the same place across your repos. Here is an example.
|
27
|
+
After installing the plugin (instructions above), you must create a saltdeps.yml file somewhere in your repo. This file along with your grains and pillar files must live in the same place across your repos. Here is an example.
|
28
28
|
|
29
29
|
```
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
name: test
|
31
|
+
deps:
|
32
|
+
apache:
|
33
|
+
git: git@github.com:saltstack-formulas/apache-formula.git
|
34
|
+
branch: develop
|
33
35
|
```
|
34
|
-
|
35
|
-
|
36
|
+
* **name** - The name of your current formula, and the folder in the same directory as the Vagrantfile where your salt state data exists. This also determines the name of the folder created in `/srv/salt`
|
37
|
+
* **deps** - A list of dependencies for your formula
|
38
|
+
* **apache** - In this example we are telling saltdeps that we expect a folder in this repo with our salt states to be called apache. This also determins the folder names that saltdeps creates
|
39
|
+
* **git** - The git repo to checkout from. Currently only git ssh protocol is supported.
|
40
|
+
* **branch** - The branch of the dependent fromula you would like to check out
|
41
|
+
|
42
|
+
After defining a saltdeps.yml file you must configure your Vagrantfile. You should put the vagrant-saltdeps provisioner before your salt provisioner since it touches the salt provisioner configuration.
|
36
43
|
|
37
44
|
```
|
38
45
|
# -*- mode: ruby -*-
|
@@ -78,20 +85,20 @@ end
|
|
78
85
|
|
79
86
|
```
|
80
87
|
|
81
|
-
This will get you started using the plugin. For further plugin configuration options please read below.
|
88
|
+
This will get you started using the plugin. For further plugin configuration options please read below.
|
82
89
|
|
83
|
-
With the example above a new folder will be created in `.vagrant-salt/deps` called `apache-formula`. In this folder saltdeps will checkout the development branch from git and search to see if any grains or pillar files from that formula need to be merged into this formula's current grains and pillars. It will then configure the salt provisioner so it has access to the grain and pillar data and sync the apache formula to the vagrant vm.
|
90
|
+
With the example above a new folder will be created in `.vagrant-salt/deps` called `apache-formula`. In this folder saltdeps will checkout the development branch from git and search to see if any grains or pillar files from that formula need to be merged into this formula's current grains and pillars. It will then configure the salt provisioner so it has access to the grain and pillar data and sync the apache formula to the vagrant vm.
|
84
91
|
|
85
|
-
## Configuration
|
92
|
+
## Configuration
|
86
93
|
|
87
|
-
This project exposes a few configuration options so you can decide the best way to lay out your salt-formula and still be able to test it in vagrant.
|
94
|
+
This project exposes a few configuration options so you can decide the best way to lay out your salt-formula and still be able to test it in vagrant.
|
88
95
|
|
89
96
|
* **checkout_path** - Where you want saltdeps to checkout your dependent formulas. Defaults to `.saltdeps`
|
90
|
-
* **deps_path** - The path to
|
97
|
+
* **deps_path** - The path to your saltdeps.yml file. Defaults to `.vagrant-salt/saltdeps.yml'
|
91
98
|
* **grains_path** - The path in **all** your repos where the grains file can be found. Defaults to `.vagrant-salt/grains`
|
92
99
|
* **pillars_path** - The path in **all** your repos where the pillars file can be found. Defaults to `.vagrant-salt/pillars`
|
93
100
|
* **merge_pillars** - Tells saltdeps if it should merge your dependent pillars into one file. Defaults to `true`.
|
94
|
-
* **merge_grains** - Tells saltdeps if it should merge your dependent grains into one file. Defaults to `true`.
|
101
|
+
* **merge_grains** - Tells saltdeps if it should merge your dependent grains into one file. Defaults to `true`.
|
95
102
|
* **merge_path** - Path where saltdeps should put the results of the merged pillars and grains files. Defaults to `.vagrant-salt/compiled_grains` and `.vagrant-salt/compiled_pillars`.
|
96
103
|
|
97
104
|
|
@@ -104,7 +111,7 @@ To work on the `vagrant-saltdeps` plugin, fork this repository out, and use
|
|
104
111
|
$ bundle _1.7.13_
|
105
112
|
```
|
106
113
|
|
107
|
-
Currently there are not unit tests, but to test you can go to a directory with a Vagrantfile and run the following.
|
114
|
+
Currently there are not unit tests, but to test you can go to a directory with a Vagrantfile and run the following.
|
108
115
|
|
109
116
|
```
|
110
117
|
$ bundle _1.7.13_ exec vagrant provision
|
@@ -10,14 +10,15 @@ module VagrantPlugins
|
|
10
10
|
class Provisioner < Vagrant.plugin('2', :provisioner)
|
11
11
|
def initialize(machine, config)
|
12
12
|
super
|
13
|
-
@logger
|
14
|
-
@checkout_path
|
15
|
-
@grains_path
|
16
|
-
@pillars_path
|
17
|
-
@merge_pillars
|
18
|
-
@merge_grains
|
19
|
-
@merged_path
|
20
|
-
@deps
|
13
|
+
@logger = Log4r::Logger.new("vagrant::provisioner::saltdeps")
|
14
|
+
@checkout_path = config.checkout_path
|
15
|
+
@grains_path = config.grains_path
|
16
|
+
@pillars_path = config.pillars_path
|
17
|
+
@merge_pillars = config.merge_pillars
|
18
|
+
@merge_grains = config.merge_grains
|
19
|
+
@merged_path = config.merged_path
|
20
|
+
@deps = YAML.load_file(config.deps_path)['deps'] || {}
|
21
|
+
@current_formula = YAML.load_file(config.deps_path)['name']
|
21
22
|
@formula_folders = []
|
22
23
|
end
|
23
24
|
|
@@ -57,10 +58,12 @@ module VagrantPlugins
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def provision
|
61
|
+
communicator = @machine.communicate
|
60
62
|
@formula_folders.each do |folder|
|
61
|
-
communicator = @machine.communicate
|
62
63
|
communicator.upload(folder[:host_path],folder[:guest_path])
|
63
64
|
end
|
65
|
+
current_path = File.expand_path(@current_formula, @machine.env.root_path)
|
66
|
+
communicator.upload(current_path,'/srv/salt')
|
64
67
|
end
|
65
68
|
|
66
69
|
def cleanup
|
@@ -72,7 +75,10 @@ module VagrantPlugins
|
|
72
75
|
FileUtils.rm(@merged_path + '/compiled_pillars') if File.exists? @merged_path + '/compiled_pillars'
|
73
76
|
end
|
74
77
|
cleanup_check_path = self.clean_up_path
|
75
|
-
@deps.keys
|
78
|
+
cleanup_folders = @deps.keys
|
79
|
+
cleanup_folders << @current_formula
|
80
|
+
|
81
|
+
cleanup_folders.each do |dep|
|
76
82
|
FileUtils.rm_rf(cleanup_check_path + '/' + dep) if File.directory?(cleanup_check_path + '/' + dep)
|
77
83
|
end
|
78
84
|
end
|
@@ -94,7 +100,7 @@ module VagrantPlugins
|
|
94
100
|
merge(@pillars_path, output_path)
|
95
101
|
@machine.config.vm.provisioners.each do |provisioner|
|
96
102
|
next unless provisioner.type == :salt
|
97
|
-
provisioner.config.pillar(YAML.load_file(output_path))
|
103
|
+
provisioner.config.pillar(YAML.load_file(output_path) || {})
|
98
104
|
end
|
99
105
|
end
|
100
106
|
end
|
@@ -102,12 +108,12 @@ module VagrantPlugins
|
|
102
108
|
def merge(path, output)
|
103
109
|
local_path = File.expand_path(path, @machine.env.root_path)
|
104
110
|
|
105
|
-
merge_object = File.
|
111
|
+
merge_object = File.exists?(local_path) ? YAML.load_file(local_path) || {} : {}
|
106
112
|
@formula_folders.each do |folder|
|
107
113
|
split_host_path = folder[:host_path].split('/')
|
108
114
|
base_dep_path = split_host_path[0..(split_host_path.length-2)].join('/')
|
109
115
|
dep_path = File.expand_path(base_dep_path + '/' + path, @machine.env.root_path)
|
110
|
-
merge_object.deep_merge!(YAML.load_file(dep_path)) if File.
|
116
|
+
merge_object.deep_merge!(YAML.load_file(dep_path) || {}) if File.exists?(dep_path)
|
111
117
|
end
|
112
118
|
|
113
119
|
File.open(output, 'w') {|f| f.write merge_object.to_yaml }
|