This repository has been archived by the owner on Oct 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
76 lines (63 loc) · 2.53 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Before running vagrant, export the shell variable for the organization on Hosted Chef and
# make sure the validator certificate is in ~/.chef.
#
# export OPSCODE_ORGNAME=your_platform_organization
#
# Also be sure to export the shell variable for the vagrant box (linux flavor) you will be using
#
# export VAGRANT_BOX=opscode-ubuntu-10.04
#
# You can optionally export a shell variable for your Chef server username if it is different
# from your OS user export OPSCODE_USER=bofh
require 'chef'
require 'chef/config'
require 'chef/knife'
require 'vagrant/provisioners/chef' # put this at the top of the Vagrant file
user = ENV['OPSCODE_USER'] || ENV['USER']
orgname = ENV['OPSCODE_ORGNAME'] || 'rabbitmq_test'
base_box = ENV['VAGRANT_BOX'] || 'opscode-ubuntu-10.04'
# Chef Server
server = "https://api.opscode.com/organizations/#{orgname}"
OMNIBUS_CHEF_VERSION = "11.6.0"
Vagrant::Config.run do |config|
config.berkshelf.node_name = user
config.berkshelf.config_path = ".chef/knife.rb"
config.berkshelf.client_key = "#{ENV['HOME']}/.chef/#{user}.pem"
config.vm.box = base_box
config.vm.network :hostonly, "33.33.33.100"
%w{nagios-plugins-rabbitmq}.each do |repo|
config.vm.share_folder "#{repo}", "/opt/#{repo}", "../#{repo}"
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{repo}", "1"]
end
config.vm.provision :shell, :path => "scripts/bootstrap.sh"
config.vm.provision :shell, :inline => <<-INSTALL_OMNIBUS
if [ ! -d "/opt/chef" ] ||
[ ! $(chef-solo --v | awk "{print \\$2}") = "#{OMNIBUS_CHEF_VERSION}" ]
then
wget -qO- https://www.opscode.com/chef/install.sh | sudo bash -s -- -v #{OMNIBUS_CHEF_VERSION}
else
echo "Chef #{OMNIBUS_CHEF_VERSION} already installed...skipping installation."
fi
INSTALL_OMNIBUS
config.vm.provision :chef_client do |chef|
chef.chef_server_url = server
chef.validation_key_path = "#{ENV['HOME']}/.chef/validators/#{orgname}-validator.pem"
chef.validation_client_name = "#{orgname}-validator"
# Change the node/client name for the Chef Server
chef.node_name = "vagrant-rabbitmq"
# Put the client.rb in /etc/chef so chef-client can be run w/o specifying
chef.provisioning_path = "/etc/chef"
# logging
#chef.log_level = :info
chef.json = {
"rabbitmq" => {
"version" => "3.1.5",
"use_distro_version" => false
}
}
chef.run_list = [ "recipe[rabbitmq_service]",
"recipe[nagios::client]",
"role[monitoring]"
]
end
end