#Version 0.1 # Command system/custom/add packages .... $packagesinstall = <<-SCRIPT # Package custom sudo yum install -y lsof vim git bind-utils # Package to Splunk health check iowait sudo yum install -y sysstat # Package installing echo "# Splunk RPM installation" sudo yum localinstall -y /vagrant/splunk-8.2.1-ddff1c41e5cf-linux-2.6-x86_64.rpm # Setup Splunk config echo "# Set permissions on Splunk folder" sudo chown -R vagrant:vagrant /opt/splunk # Splunk apps : # Manage min Free Space to POC instance echo "# Set minFreeSpace to POC instance" sudo mkdir -p /opt/splunk/etc/apps/my_customsplunk/local/ sudo echo "[diskUsage]" > /opt/splunk/etc/apps/my_customsplunk/local/server.conf sudo echo "minFreeSpace = 50" >> /opt/splunk/etc/apps/my_customsplunk/local/server.conf sudo chown -R vagrant:vagrant /opt/splunk/etc/apps/my_customsplunk/ echo "# Splunk activation on boot with Vagrant user" sudo /opt/splunk/bin/splunk enable boot-start -systemd-managed 1 --accept-license -user vagrant --seed-passwd changeme echo "# Launch Splunk" sudo /opt/splunk/bin/splunk start --no-prompt SCRIPT #Get IP to display after vagrant up $getip= <<-SCRIPT echo "IP of $(hostname) : " ip -4 addr sh eth1 echo "" echo "Splunk Version ; " /opt/splunk/bin/splunk version SCRIPT #Message post up $postupmessage = <<-SCRIPT Congratulations VM/box available. Generate by Vagrant ! SCRIPT #Customise OS env $customenv= <<-SCRIPT echo "Custom environnement" #Bash profile # echo "Set Bash profile to all users" # sudo curl -sk "https://raw.githubusercontent.com/alasta/dotfiles/master/.bash_profile_vagrant" -o /etc/profile.d/bash_profile.sh echo "Set .bash_profile to Vagrant user" sudo curl -sk "https://raw.githubusercontent.com/alasta/dotfiles/master/.bash_profile_vagrant" -o /home/vagrant/.bash_profile #inputrc echo "Set inputrc" #curl -sk "https://raw.githubusercontent.com/alasta/dotfiles/master/.inputrc" -o INPUTRC #sudo cat INPUTRC >> /etc/inputrc #rm -f INPUTRC echo "Set inputrc to Vagrant user" sudo curl -sk "https://raw.githubusercontent.com/alasta/dotfiles/master/.inputrc" -o /home/vagrant/.inputrc #.vimrc echo "Set vimrc" sudo curl -sk "https://raw.githubusercontent.com/alasta/dotfiles/master/.vimrc" -o /home/vagrant/.vimrc #bash profile and inputrc to root sudo curl -sk "https://raw.githubusercontent.com/alasta/dotfiles/master/.bash_profile_root" -o /root/.bash_profile #Set timezone echo "# Set timezone" timedatectl set-timezone 'Europe/Paris' # Manage DNS server to disable DNS on private net echo "# Disable DNS private net" sudo sed -i -e 's/.*10.0/#&/g' /etc/resolv.conf SCRIPT #Config box Vagrant.configure("2") do |config| (1..3).each do |i| config.vm.define "shc#{i}" do |vm1| #vm1.vm.provider "virtualbox" do |v| # v.memory = 2048 # v.cpus = 2 #end #vm1.vm.box = "centos/7" vm1.vm.box = "centos/8" vm1.vm.hostname = "shc#{i}" vm1.vm.box_url = "centos/8" vm1.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", auto_config: false vm1.vm.provision "file", source: "~/Downloads/splunk-8.2.1-ddff1c41e5cf-linux-2.6-x86_64.rpm", destination: "/vagrant/" vm1.vm.provision "shell", inline: $packagesinstall vm1.vm.provision "shell", inline: $customenv vm1.vm.provision "shell", inline: $getip, run: "always" vm1.vm.post_up_message = $postupmessage #vm1.vm.provision "shell", inline: "ip -4 addr sh eth1", run: "always" end end config.vm.define "us1" do |vm1| #vm1.vm.provider "virtualbox" do |v| # v.memory = 2048 # v.cpus = 2 #end #vm1.vm.box = "centos/7" vm1.vm.box = "centos/8" vm1.vm.hostname = 'us1' vm1.vm.box_url = "centos/8" vm1.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", auto_config: false vm1.vm.provision "file", source: "~/Downloads/splunk-8.2.1-ddff1c41e5cf-linux-2.6-x86_64.rpm", destination: "/vagrant/" vm1.vm.provision "shell", inline: $packagesinstall vm1.vm.provision "shell", inline: $customenv vm1.vm.provision "shell", inline: $getip, run: "always" vm1.vm.post_up_message = $postupmessage #vm1.vm.provision "shell", inline: "ip -4 addr sh eth1", run: "always" end end