This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Vagrantfile
81 lines (68 loc) · 2.2 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
76
77
78
79
80
81
#e -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
VAGRANTFILE_LOCAL = 'Vagrantfile.local'
sdist=ENV['CIF_ANSIBLE_SDIST']
es=ENV['CIF_ANSIBLE_ES']
hunter_threads=ENV['CIF_HUNTER_THREADS']
hunter_advanced=ENV['CIF_HUNTER_ADVANCED']
geo_fqdn=ENV['CIF_GATHERER_GEO_FQDN']
csirtg_token=ENV['CSIRTG_TOKEN']
distro=ENV.fetch('CIF_VAGRANT_DISTRO', 'ubuntu')
redhat=0
rhel_user=ENV['RHEL_USER']
rhel_pass=ENV['RHEL_PASSWORD']
es_tests=ENV.fetch('CIF_ELASTICSEARCH_TEST', '0')
es_upsert=ENV.fetch('CIF_STORE_ES_UPSERT_MODE', '0')
redhat=1 if distro == 'redhat'
unless File.directory?('deploymentkit')
puts "Please unzip the latest release of the deploymentkit before continuing..."
puts ""
puts "https://github.com/csirtgadgets/bearded-avenger-deploymentkit/wiki"
puts ""
exit
end
$script = <<SCRIPT
export CIF_ANSIBLE_SDIST=#{sdist}
export CIF_ANSIBLE_ES=#{es}
export CIF_ELASTICSEARCH_TEST=#{es_tests}
export CIF_STORE_ES_UPSERT_MODE=#{es_upsert}
export CIF_HUNTER_THREADS=#{hunter_threads}
export CIF_HUNTER_ADVANCED=#{hunter_advanced}
export CIF_GATHERER_GEO_FQDN=#{geo_fqdn}
export CIF_BOOTSTRAP_TEST=1
export CSIRTG_TOKEN=#{csirtg_token}
export RHEL=#{redhat}
export USERNAME=#{rhel_user}
export PASSWORD="#{rhel_pass}"
if [ "${RHEL}" == "1" ]; then
subscription-manager register --username "${USERNAME}" --password "${PASSWORD}" --auto-attach
subscription-manager attach
fi
cd /vagrant/deploymentkit
bash easybutton.sh
if [ "${RHEL}" == "1" ]; then
echo 'unregistering'
subscription-manager unregister
fi
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", inline: $script
case distro
when 'redhat'
config.vm.box = "iamseth/rhel-7.3"
when 'centos'
config.vm.box = 'geerlingguy/centos7'
else
config.vm.box = 'ubuntu/xenial64'
end
#config.vm.network :forwarded_port, guest: 443, host: 8443
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--cpus", "2", "--ioapic", "on", "--memory", "4096" ]
end
if File.file?(VAGRANTFILE_LOCAL)
external = File.read VAGRANTFILE_LOCAL
eval external
end
end