-
Notifications
You must be signed in to change notification settings - Fork 9
/
Vagrantfile
196 lines (179 loc) · 7.28 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#Global Cybersecurity Resource 2017-2018 (cugcr.ca)
#
##########################################################################
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
#a distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
#ABOUT:
#-------------------
#This Vagrant file will deploy Apache Metron as a single node instance (node1) to AWS EC2.
#
#This file was originally adapted from the Metron Single Node Install Vagrant file located here:
#https://cwiki.apache.org/confluence/display/METRON/Dev+VM+Install
#https://github.com/apache/metron/blob/master/metron-deployment/vagrant/full-dev-platform/Vagrantfile
##########################################################################
#LOCATION OF FILE:
#-------------------
#This file should be located in the following directory:
#/../metron-deployment/vagrant/full-dev-platform
##########################################################################
#REQUIREMENTS(What is needed to run this file):
#-------------------
#install: vagrant plugin install vagrant-aws
#install: vagrant plugin install vagrant-reload
#install: vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
#install: pip install --upgrade setuptools --user python
#
#You will also need to reserve an AWS Elastic IP and have a Subnet id and Security Group id
#In the code below you will see "<_comment_>" letting you know where to place the ids
##########################################################################
#BEFORE RUNNING:
#Recommended steps before running file (clearing vagrant, docker, ext..):
#-------------------
#vagrant halt node1 -f
#vagrant halt default -f
#vagrant destroy node1 -f
#vagrant destroy default -f
#for i in `vagrant global-status | grep virtualbox | awk '{print $1 }'` ; do vagrant destroy $i ; done
#vagrant global-status --prune
#docker rm $(docker ps -aq)
#osascript -e 'quit app "Docker"'
#open -a Docker
#rm -rf /../.m2/repository/*
#rm -rf /../.vagrant.d/boxes/*
#vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
##########################################################################
#HOW TO EXECUTE THIS FILE:
#-------------------
#Set Environment Variables & Run Vagrant
#-------------------
#export AWS_ACCESS_KEY_ID=''
#export AWS_SECRET_ACCESS_KEY=''
#export AWS_KEYNAME=''
#export AWS_KEYPATH='../..*.pem'
#
#export AWS_ELASTICIP=""
#export AWS_SECURITYGROUPID=""
#export AWS_SUBNETID=""
#
#vagrant up --provider=aws
##########################################################################
#OTHER NOTES:
#-------------------
#How to find Canadian Centos7 AMI ids:
#run: pip install awscli
#run: aws --region ca-central-1 ec2 describe-images --owners aws-marketplace --filters Name=product-code,Values=aw0evgkw8e5c1q413zgy5pjce
#imageIDs: ami-28823e4c, ami-af62d0cb, ami-cbd069af
require 'getoptlong'
require 'vagrant-aws'
require 'vagrant-reload'
ansibleTags=''
ansibleSkipTags='sensors,quick_dev'
begin
opts = GetoptLong.new(
[ '--ansible-tags', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--ansible-skip-tags', GetoptLong::OPTIONAL_ARGUMENT ]
)
opts.quiet = TRUE
opts.each do |opt, arg|
case opt
when '--ansible-tags'
ansibleTags=arg
when '--ansible-skip-tags'
ansibleSkipTags=arg
end
end
rescue Exception => ignored
#Ignore to allow other opts to be passed to Vagrant
end
puts " Running with ansible-tags: " + ansibleTags.split(",").to_s if ansibleTags != ''
puts " Running with ansible-skip-tags: " + ansibleSkipTags.split(",").to_s if ansibleSkipTags != ''
hosts = [{
hostname: "node1",
ip: ENV['AWS_ELASTICIP'],
memory: "6000",
cpus: 4,
promisc: 2 # enables promisc on the 'Nth' network interface
}]
Vagrant.configure(2) do |config|
config.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
aws.keypair_name = ENV['AWS_KEYNAME']
#Below is a CentOS ami id available in Canada
aws.ami = "ami-00e45864"
aws.region = "ca-central-1"
aws.instance_type = "t2.2xlarge"
#Example of a Security Group id: sg-1193xxxx
aws.security_groups = ENV['AWS_SECURITYGROUPID']
#Example of Subnet id: subnet-fbc3exxxx
aws.subnet_id = ENV['AWS_SUBNETID']
aws.elastic_ip = ENV['AWS_ELASTICIP']
override.vm.box = "dummy"
override.ssh.username = "centos"
override.ssh.private_key_path = ENV['AWS_KEYPATH']
#config.vm.provider "aws" do |aws, override|
override.nfs.functional = false
aws.tags = {
'Name' => 'Phase1.5-MetronA-TESTING',
'Organization' => 'GCR',
'Developer' => 'GCR Dev Team',
'Function' => 'MetronInstall'
}
aws.block_device_mapping = [{'DeviceName' =>'/dev/sda1', 'Ebs.VolumeSize' => 100, 'Ebs.DeleteOnTermination' => true}]
end
#The following will install rsyslog, change hostname to node1, resize the disk partition, and reboot
config.vm.provision "shell", inline: <<-SHELL
yum install -y wget
yum install yum-utils
#wget http://rpms.adiscon.com/v8-stable/rsyslog.repo
#mv rsyslog.repo /etc/yum.repos.d/rsyslog.repo
#yum info rsyslog --skip-broken
#yum install -y rsyslog
yum-config-manager --add-repo http://rpms.adiscon.com/v8-stable/epel-6/x86_64
yum install --nogpg -y rsyslog rsyslog-kafka
rm /etc/rsyslog.d/listen.conf
rsyslogd -N1 && rsyslogd
hostname node1
sed -i "s/^HOSTNAME=.*/HOSTNAME=node1/g" /etc/sysconfig/network
echo -e "u s\nd 1\nn\np\n1\n2048\n\na\n1\nw\n" | fdisk /dev/xvda
ip link set eth0 promisc on
ifconfig eth0 promisc
#(echo u s; echo d 1; echo n; echo p; echo 1; echo 2048 ; echo ;echo a; echo 1; echo w) | fdisk {{ vol_src_1 }} || true
#
#INSTALL NIFI
#-------------------
#sudo -i
#cd /opt
#wget https://archive.apache.org/dist/nifi/1.2.0/nifi-1.2.0-bin.tar.gz
#tar xf nifi-1.2.0-bin.tar.gz
#note: modify nifi-1.1.2/conf/nifi.properties to change "nifi.web.http.port" to port 8089
#sed -i "s/^nifi\.web\.http\.port=.*/nifi\.web\.http\.port=8089/g" /opt/nifi-1.2.0/conf/nifi.properties
#/opt/nifi-1.2.0/bin/nifi.sh install
#/opt/nifi-1.2.0/bin/nifi.sh stop
#/opt/nifi-1.2.0/bin/nifi.sh start
shutdown -r now
SHELL
config.vm.provision :reload
config.vm.provision :ansible do |ansible|
ansible.playbook = "../../playbooks/metron_full_install.yml"
ansible.host_key_checking = false
ansible.limit = 'all'
ansible.sudo = true
ansible.tags = ansibleTags.split(",") if ansibleTags != ''
ansible.skip_tags = ansibleSkipTags.split(",") if ansibleSkipTags != ''
ansible.inventory_path = "../../inventory/full-dev-platform"
end
end