Skip to content

Instantly share code, notes, and snippets.

@vdanen
Created November 23, 2016 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdanen/ed8ec7c0be8ec844dc20158045638404 to your computer and use it in GitHub Desktop.
Save vdanen/ed8ec7c0be8ec844dc20158045638404 to your computer and use it in GitHub Desktop.
Vagrantfile for otter
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "puppetlabs/centos-7.0-64-nocm"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# forward port 5000 on the localhost to port 5000 in the guest
config.vm.network "forwarded_port", guest: 80, host: 5000
config.vm.network "forwarded_port", guest: 3306, host: 3306
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder ".", "/srv/www/otter"
config.vm.define :otter
# if ARGV[1] and (ARGV[1].split('=')[0] == "--provider" or ARGV[2])
# provider = (ARGV[1].split('=')[1] || ARGV[2])
# else
# provider = (ENV['VAGRANT_DEFAULT_PROVIDER'] || :virtualbox).to_sym
# end
# if provider == "virtualbox"
# config.vm.provider "virtualbox" do |v|
# # 2GB memory for virtualbox
# v.memory = 2048
# end
# end
# if provider == "vmware_fusion"
config.vm.provider "vmware_fusion" do |v|
# 2GB memory for vmware fusion
v.vmx["memsize"] = "2048"
v.name = "otter"
end
# end
config.vm.post_up_message = "Otter is available at http://localhost:5000 ; to start it 'cd /srv/www/otter; ./run.py'. NOTE: you must first run /home/vagrant/mysql-setup.sh to setup MySQL."
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
# this runs as root
config.vm.provision "shell", inline: <<-SHELL
yum update -y
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
yum install httpd mariadb-devel postgresql-devel mariadb-server python-virtualenv python-pip gcc gcc-c++ freetype-devel libpng-devel python-requests MySQL-python python-psycopg2 python-bugzilla krb5-workstation openldap-clients mailx python-simplejson python-kerberos vim -y
firewall-cmd --permanent --zone=public --add-service=mysql
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-port=5000/tcp
firewall-cmd --reload
systemctl enable mariadb
systemctl start mariadb
systemctl enable httpd
systemctl start httpd
echo '[mysql]' >/home/vagrant/.my.cnf
echo 'host = localhost' >>/home/vagrant/.my.cnf
echo 'user = otter' >>/home/vagrant/.my.cnf
echo 'password = "password"' >>/home/vagrant/.my.cnf
chown vagrant:vagrant /home/vagrant/.my.cnf
echo '#!/bin/sh' >/home/vagrant/mysql-setup.sh
echo 'sudo /usr/bin/mysql_secure_installation' >>/home/vagrant/mysql-setup.sh
echo 'cat mysql-commands.txt | mysql -u root -p' >>/home/vagrant/mysql-setup.sh
echo "CREATE DATABASE otter; GRANT ALL ON otter.* TO 'otter'@'localhost' IDENTIFIED BY 'otter';" >>/home/vagrant/mysql-commands.txt
echo "GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'password';" >>/home/vagrant/mysql-commands.txt
echo "FLUSH PRIVILEGES;" >>/home/vagrant/mysql-commands.txt
chmod 0755 /home/vagrant/mysql-setup.sh
mkdir -p /srv/www/otter
cd /srv/www/otter
if [ -d flask ]; then
rm -rf flask
fi
./setup.sh
cp /home/vagrant/.my.cnf /srv/www/otter/
cp -f config/otter.service /etc/systemd/system/
cp -f config/otter.socket /etc/systemd/system/
cp -f config/tmpfiles.d-otter.conf /etc/tmpfiles.d/
systemctl enable otter.service
systemctl enable otter.socket
systemd-tmpfiles --create
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment