Hi there!
I was thinking is maybe is possible to use several shell scripts to provision the machine.
I mean, instead to have a big one, use different ones, with the concept from configuration management.
I have a nodes. json definition as this one:
{
"nodes": {
"vagrant.domain": {
":ip": "192.168.32.5",
"ports": [],
":memory": 2048,
"bootstrap": ["bootstrap-hosts.sh","bootstrap-centos.sh"]
}
}
}
And I was trying something like this in my vagrant file ….
# vi: set ft=ruby :
# Builds Puppet Master and multiple Puppet Agent Nodes using JSON config file
# Author: Gary A. Stafford
# read vm and chef configurations from JSON files
nodes_config = (JSON.parse(File.read("nodes.json")))['nodes']
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos/7"
nodes_config.each do |node|
node_name = node[0] # name of node
node_values = node[1] # content of node
config.vm.define node_name do |config|
# configures all forwarding ports in JSON array
ports = node_values['ports']
ports.each do |port|
config.vm.network :forwarded_port,
host: port[':host'],
guest: port[':guest'],
id: port[':id'],
auto_correct: true
end
config.vm.hostname = node_name
config.vm.network :private_network, ip: node_values[':ip']
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
vb.customize ["modifyvm", :id, "--name", node_name]
end
# config.vm.provision :shell, :path => node_values[':bootstrap']
valores = node_values['bootstrap']
valores.each do |v|
#puts v.upcase
config.vm.provision :shell, path=> v.upcase
end
end
end
end
Thanks!
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/1bea458f-88df-44eb-8f5c-feff5d2f4bf9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wow looks really interesting! I guess that is I was looking for, the way to put some scripts there…
|
"scripts": [ |
|
|
"update.sh", |
|
|
"supervisor.sh", |
|
|
"git.sh", |
|
|
"node.sh", |
|
|
"global_node_modules.sh", |
|
|
"ssh.sh" |
|
|
] |
I guess that part in addition with the libraries, specially the config_virtualbox
|
|
|
|
# Global |
|
|
server["host_scripts"].each do |script, key| |
|
|
instance.vm.provision :host_shell do |host_shell| |
|
|
host_shell.inline = './host_scripts/' + script |
|
|
end |
|
|
end |
So thanks a million for your reply!
Gracias!
JC
You received this message because you are subscribed to a topic in the Google Groups "Vagrant" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vagrant-up/CNoO9toLiJo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0ezA-ajD7Vvvc22KOoizQ6Ke420VAoi_NXBUeXAU%3DnTA6w%40mail.gmail.com.