vagrant-compose 0.7.0 → 0.7.1
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/.gitignore +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/vagrant/compose/declarative/cluster.rb +78 -73
- data/lib/vagrant/compose/version.rb +1 -1
- metadata +2 -3
- data/provisioning/group_vars/zookeeper.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2ca4a2adb7273d09c0650fa06fc3d3f059d8e3a
|
4
|
+
data.tar.gz: 95c5b8b69f87f119e51b76507cba24716902625c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f24a63d849bd0b574bed06bdcc1e454b6549f93a1ef0bd4367888541cf889f5bdf79f5e13ccfc320c9a546ce4712181428e5a5a905ba2c56a335b42753df30d8
|
7
|
+
data.tar.gz: 1a682bf36be2fb2d1b6501bbae5ed7b04e29d206d7c8aa45192b584d0ecdd37f58787c2f2357d0e37826a44bd27eccc0b9503f633a5719c8a9cb217973db9496
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -33,13 +33,13 @@ Vagrant-compose supports two appraches for definining a cluster of VMs.
|
|
33
33
|
|
34
34
|
Cluster are defined by using the some ruby knowledge that is required for writing Vagrantfiles.
|
35
35
|
|
36
|
-
see [Programmatic Approach](
|
36
|
+
see [Programmatic Approach](https://github.com/fabriziopandini/vagrant-compose/blob/master/doc/programmatic.md) for more details.
|
37
37
|
|
38
38
|
- Declarative Approach
|
39
39
|
|
40
40
|
By using the declarative approach also people with limited programming background can use vagrant-compose to easily define a cluster composed by many VMs; with declarative approach, the definition of the cluster is done in yaml, and the ruby programming part within the Vagrantfile is reduced to the minimum.
|
41
41
|
|
42
|
-
see [Declarative Approach](
|
42
|
+
see [Declarative Approach](https://github.com/fabriziopandini/vagrant-compose/blob/master/doc/declarative.md) for more details.
|
43
43
|
|
44
44
|
# Additional notes
|
45
45
|
Vagrant compose will play nicely with all vagrant commands.
|
@@ -24,27 +24,27 @@ module VagrantPlugins
|
|
24
24
|
# It defaults to current directory/provisioning
|
25
25
|
attr_accessor :ansible_playbook_path
|
26
26
|
|
27
|
-
|
27
|
+
# Costruttore di una istanza di cluster.
|
28
28
|
def initialize()
|
29
|
-
|
29
|
+
@multimachine_filter = ""
|
30
30
|
end
|
31
31
|
|
32
32
|
# Implements cluster creation from a playbook file
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
def from (file)
|
34
|
+
# calls vagrant-playbook utility for executing the playbook file.
|
35
|
+
playbook = YAML.load(pycompose (file))
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
# extract cluster attributes
|
38
|
+
@name = playbook.keys[0]
|
39
|
+
@box = playbook[@name]['box']
|
40
|
+
@domain = playbook[@name]['domain']
|
41
|
+
@ansible_playbook_path = playbook[@name]['ansible_playbook_path']
|
42
42
|
|
43
43
|
# extract nodes
|
44
44
|
nodes = []
|
45
45
|
playbook[@name]['nodes'].each do |node|
|
46
46
|
|
47
|
-
|
47
|
+
boxname = node.keys[0]
|
48
48
|
|
49
49
|
box = node[boxname]['box']
|
50
50
|
hostname = node[boxname]['hostname']
|
@@ -64,74 +64,79 @@ module VagrantPlugins
|
|
64
64
|
# extract ansible inventory, ansible_group_vars, ansible_host_vars
|
65
65
|
ansible_groups = {}
|
66
66
|
if playbook[@name].key?("ansible")
|
67
|
-
ansible = playbook[@name]['ansible']
|
68
|
-
|
69
|
-
# extract ansible inventory
|
70
|
-
ansible_groups = ansible['inventory']
|
71
|
-
|
72
|
-
# cleanup ansible_group_vars files
|
73
|
-
# TODO: make safe
|
74
|
-
ansible_group_vars_path = File.join(@ansible_playbook_path, 'group_vars')
|
75
|
-
|
76
|
-
FileUtils.mkdir_p(ansible_group_vars_path) unless File.exists?(ansible_group_vars_path)
|
77
|
-
Dir.foreach(ansible_group_vars_path) {|f| fn = File.join(ansible_group_vars_path, f); File.delete(fn) if f.end_with?(".yml")}
|
78
|
-
|
79
|
-
#generazione ansible_group_vars file (NB. 1 group = 1 gruppo host ansible)
|
80
|
-
ansible['group_vars'].each do |group, vars|
|
81
|
-
# crea il file (se sono state generate delle variabili)
|
82
|
-
unless vars.empty?
|
83
|
-
# TODO: make safe
|
84
|
-
File.open(File.join(ansible_group_vars_path,"#{group}.yml") , 'w+') do |file|
|
85
|
-
file.puts YAML::dump(vars)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# cleanup ansible_host_vars files (NB. 1 nodo = 1 host)
|
91
|
-
# TODO: make safe
|
92
|
-
ansible_host_vars_path = File.join(@ansible_playbook_path, 'host_vars')
|
93
|
-
|
94
|
-
FileUtils.mkdir_p(ansible_host_vars_path) unless File.exists?(ansible_host_vars_path)
|
95
|
-
Dir.foreach(ansible_host_vars_path) {|f| fn = File.join(ansible_host_vars_path, f); File.delete(fn) if f.end_with?(".yml")}
|
96
|
-
|
97
|
-
#generazione ansible_host_vars file
|
98
|
-
ansible['host_vars'].each do |host, vars|
|
99
|
-
# crea il file (se sono state generate delle variabili)
|
100
|
-
unless vars.empty?
|
101
|
-
# TODO: make safe
|
102
|
-
File.open(File.join(ansible_host_vars_path,"#{host}.yml") , 'w+') do |file|
|
103
|
-
file.puts YAML::dump(vars)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
67
|
|
109
|
-
|
110
|
-
|
68
|
+
ansible = playbook[@name]['ansible']
|
69
|
+
|
70
|
+
# extract ansible inventory
|
71
|
+
ansible_groups = ansible['inventory']
|
72
|
+
|
73
|
+
# cleanup ansible_group_vars files
|
74
|
+
# TODO: make safe
|
75
|
+
ansible_group_vars_path = File.join(@ansible_playbook_path, 'group_vars')
|
76
|
+
|
77
|
+
FileUtils.mkdir_p(ansible_group_vars_path) unless File.exists?(ansible_group_vars_path)
|
78
|
+
Dir.foreach(ansible_group_vars_path) {|f| fn = File.join(ansible_group_vars_path, f); File.delete(fn) if f.end_with?(".yml")}
|
79
|
+
|
80
|
+
#generazione ansible_group_vars file (NB. 1 group = 1 gruppo host ansible)
|
81
|
+
if ansible.key?("group_vars")
|
82
|
+
ansible['group_vars'].each do |group, vars|
|
83
|
+
# crea il file (se sono state generate delle variabili)
|
84
|
+
unless vars.empty?
|
85
|
+
# TODO: make safe
|
86
|
+
File.open(File.join(ansible_group_vars_path,"#{group}.yml") , 'w+') do |file|
|
87
|
+
file.puts YAML::dump(vars)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# cleanup ansible_host_vars files (NB. 1 nodo = 1 host)
|
94
|
+
# TODO: make safe
|
95
|
+
ansible_host_vars_path = File.join(@ansible_playbook_path, 'host_vars')
|
96
|
+
|
97
|
+
FileUtils.mkdir_p(ansible_host_vars_path) unless File.exists?(ansible_host_vars_path)
|
98
|
+
Dir.foreach(ansible_host_vars_path) {|f| fn = File.join(ansible_host_vars_path, f); File.delete(fn) if f.end_with?(".yml")}
|
99
|
+
|
100
|
+
#generazione ansible_host_vars file
|
101
|
+
if ansible.key?("host_vars")
|
102
|
+
ansible['host_vars'].each do |host, vars|
|
103
|
+
# crea il file (se sono state generate delle variabili)
|
104
|
+
unless vars.empty?
|
105
|
+
# TODO: make safe
|
106
|
+
File.open(File.join(ansible_host_vars_path,"#{host}.yml") , 'w+') do |file|
|
107
|
+
file.puts YAML::dump(vars)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
111
113
|
|
114
|
+
return nodes, ansible_groups
|
115
|
+
end
|
112
116
|
|
113
|
-
# Executes pycompose command
|
114
|
-
def pycompose (file)
|
115
|
-
p_err = ""
|
116
|
-
p_out = ""
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
118
|
+
# Executes pycompose command
|
119
|
+
def pycompose (file)
|
120
|
+
p_err = ""
|
121
|
+
p_out = ""
|
122
|
+
|
123
|
+
begin
|
124
|
+
p_status = Open4::popen4("vagrant-playbook -f #{file}") do |pid, stdin, stdout, stderr|
|
125
|
+
p_err = stderr.read.strip
|
126
|
+
p_out = stdout.read.strip
|
127
|
+
end
|
128
|
+
rescue Errno::ENOENT
|
129
|
+
raise VagrantPlugins::Compose::Errors::PyComposeMissing
|
130
|
+
rescue Exception => e
|
131
|
+
raise VagrantPlugins::Compose::Errors::PyComposeError, :message => e.message
|
132
|
+
end
|
128
133
|
|
129
|
-
|
130
|
-
|
131
|
-
|
134
|
+
if p_status.exitstatus != 0
|
135
|
+
raise VagrantPlugins::Compose::Errors::PyComposeError, :message => p_err
|
136
|
+
end
|
132
137
|
|
133
|
-
|
134
|
-
|
138
|
+
return p_out
|
139
|
+
end
|
135
140
|
|
136
141
|
end
|
137
142
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabrizio Pandini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -92,7 +92,6 @@ files:
|
|
92
92
|
- lib/vagrant/compose/version.rb
|
93
93
|
- lib/vagrant/compose.rb
|
94
94
|
- LICENCE
|
95
|
-
- provisioning/group_vars/zookeeper.yml
|
96
95
|
- Rakefile
|
97
96
|
- README.md
|
98
97
|
- vagrant-compose.gemspec
|