mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
Update Vagrantfile configuration and include provisioning scripts
This commit is contained in:
parent
94224574cb
commit
b3b0928b8e
96
Vagrantfile
vendored
96
Vagrantfile
vendored
@ -1,73 +1,41 @@
|
|||||||
# -*- mode: ruby -*-
|
# -*- mode: ruby -*-
|
||||||
# vi: set ft=ruby :
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
||||||
# configures the configuration version (we support older styles for
|
VAGRANTFILE_API_VERSION = '2'
|
||||||
# backwards compatibility). Please don't change it unless you know what
|
|
||||||
# you're doing.
|
|
||||||
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
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||||
# boxes at https://atlas.hashicorp.com/search.
|
config.vm.box = 'ubuntu/xenial64'
|
||||||
config.vm.box = "ubuntu/trusty64"
|
config.vm.define 'fabmanager-devbox'
|
||||||
|
|
||||||
# Disable automatic box update checking. If you disable this, then
|
# Port forwarding
|
||||||
# boxes will only be checked for updates when the user runs
|
[
|
||||||
# `vagrant box outdated`. This is not recommended.
|
3000, # rails/puma
|
||||||
# config.vm.box_check_update = false
|
9200, # elasticsearch
|
||||||
|
5432, # postgres
|
||||||
# Create a forwarded port mapping which allows access to a specific port
|
1080, # mailcatcher web ui
|
||||||
# within the machine from a port on the host machine. In the example below,
|
4040 # ngrok web ui
|
||||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
].each do |port|
|
||||||
config.vm.network "forwarded_port", guest: 3000, host: 3000 # rails/puma
|
config.vm.network "forwarded_port", guest: port, host: port
|
||||||
config.vm.network "forwarded_port", guest: 9200, host: 9200 # elasticsearch
|
|
||||||
config.vm.network "forwarded_port", guest: 5432, host: 5432 # postgreSQL
|
|
||||||
|
|
||||||
# Create a private network, which allows host-only access to the machine
|
|
||||||
# using a specific IP.
|
|
||||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
|
||||||
|
|
||||||
# Create a public network, which generally matched to bridged network.
|
|
||||||
# Bridged networks make the machine appear as another physical device on
|
|
||||||
# your network.
|
|
||||||
# config.vm.network "public_network"
|
|
||||||
|
|
||||||
# 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 "../data", "/vagrant_data"
|
|
||||||
|
|
||||||
# Provider-specific configuration so you can fine-tune various
|
|
||||||
# backing providers for Vagrant. These expose provider-specific options.
|
|
||||||
# Example for VirtualBox:
|
|
||||||
#
|
|
||||||
config.vm.provider "virtualbox" do |vb|
|
|
||||||
# Display the VirtualBox GUI when booting the machine
|
|
||||||
# vb.gui = true
|
|
||||||
|
|
||||||
# Customize the amount of memory on the VM:
|
|
||||||
vb.memory = 512
|
|
||||||
end
|
end
|
||||||
#
|
|
||||||
# View the documentation for the provider you are using for more
|
|
||||||
# information on available options.
|
|
||||||
|
|
||||||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
# Provider-specific configuration
|
||||||
# such as FTP and Heroku are also available. See the documentation at
|
config.vm.provider 'virtualbox' do |vb|
|
||||||
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
vb.customize ['modifyvm', :id, '--memory', '1536']
|
||||||
# config.push.define "atlas" do |push|
|
end
|
||||||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Enable provisioning with a shell script. Additional provisioners such as
|
# If you are using Windows o Linux with an encrypted volume
|
||||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
config.vm.synced_folder '.', '/vagrant', type: 'virtualbox'
|
||||||
# documentation for more information about their specific syntax and use.
|
|
||||||
# config.vm.provision "shell", inline: <<-SHELL
|
# Provisioning
|
||||||
# sudo apt-get update
|
config.vm.provision "shell", privileged: true, run: "always" do |s|
|
||||||
# sudo apt-get install -y apache2
|
s.inline = "export LC_ALL=en_US.UTF-8\n" \
|
||||||
# SHELL
|
"export LANG=en_US.UTF-8\n" \
|
||||||
|
"export LANGUAGE=en_US.UTF-8"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.provision "shell", privileged: false, run: "once",
|
||||||
|
path: "provision/zsh_setup.sh"
|
||||||
|
config.vm.provision "shell", privileged: false, run: "once",
|
||||||
|
path: "provision/box_setup.zsh"
|
||||||
end
|
end
|
||||||
|
181
provision/box_setup.zsh
Executable file
181
provision/box_setup.zsh
Executable file
@ -0,0 +1,181 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# Install and setup PostgreSQL ################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo "Checking Postgres installation..."
|
||||||
|
echo "***************************************************"
|
||||||
|
if ! dpkg -s postgresql; then
|
||||||
|
echo "Installing PostgreSQL"
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y postgresql postgresql-contrib
|
||||||
|
|
||||||
|
echo "Setting up user"
|
||||||
|
sudo -u postgres bash -c "psql -c \"CREATE USER ubuntu WITH PASSWORD 'ubuntu';\""
|
||||||
|
sudo -u postgres bash -c "psql -c \"ALTER USER ubuntu WITH SUPERUSER;\""
|
||||||
|
|
||||||
|
echo "Setting up extensions to all schemas"
|
||||||
|
sudo -u postgres bash -c "psql -c \"CREATE EXTENSION unaccent SCHEMA pg_catalog;\""
|
||||||
|
sudo -u postgres bash -c "psql -c \"CREATE EXTENSION pg_trgm SCHEMA pg_catalog;\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo " Starting Postgres server "
|
||||||
|
echo "***************************************************"
|
||||||
|
sudo service postgresql start
|
||||||
|
|
||||||
|
|
||||||
|
# Install Redis ###############################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo "Checking Redis installation..."
|
||||||
|
echo "***************************************************"
|
||||||
|
if ! dpkg -s redis-server; then
|
||||||
|
echo "Instalating Redis"
|
||||||
|
sudo apt install -y redis-server
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Install Imagemagick #########################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo "Checking Imagemagik installation..."
|
||||||
|
echo "***************************************************"
|
||||||
|
if ! dpkg -s imagemagick; then
|
||||||
|
sudo apt install -y imagemagick
|
||||||
|
else
|
||||||
|
echo 'OK'
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Install Elastic Search ######################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo "Checking ElasticSearch installation..."
|
||||||
|
echo "***************************************************"
|
||||||
|
if ! dpkg -s elasticsearch; then
|
||||||
|
sudo apt install -y openjdk-8-jre apt-transport-https
|
||||||
|
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
|
||||||
|
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
|
||||||
|
sudo apt update && sudo apt install -y elasticsearch
|
||||||
|
|
||||||
|
# This configuration limits ElasticSearch memory use inside the virtual machine
|
||||||
|
sudo echo "node.master: true" >> /etc/elasticsearch/elasticsearch.yml
|
||||||
|
sudo echo "node.data: false" >> /etc/elasticsearch/elasticsearch.yml
|
||||||
|
sudo sed -i 's/#bootstrap.memory_lock: true/bootstrap.memory_lock: true/g' /etc/elasticsearch/elasticsearch.yml
|
||||||
|
sudo sed -i 's/#ES_JAVA_OPTS=/ES_JAVA_OPTS="-Xms256m -Xmx256m"/g' /etc/default/elasticsearch
|
||||||
|
|
||||||
|
sudo /bin/systemctl daemon-reload
|
||||||
|
sudo /bin/systemctl enable elasticsearch.service
|
||||||
|
else
|
||||||
|
echo 'OK'
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Install Ngrok exposer ######################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo "Checking for Ngrok... "
|
||||||
|
echo "***************************************************"
|
||||||
|
if ! ngrok; then
|
||||||
|
sudo apt install -y unzip
|
||||||
|
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
|
||||||
|
sudo unzip ngrok-stable-linux-amd64.zip -d /usr/local/bin
|
||||||
|
rm -rf ngrok-stable-linux-amd64.zip
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Install Node Version Manager ################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo "Checking for NVM... "
|
||||||
|
echo "***************************************************"
|
||||||
|
if [[ ! -x "$HOME/.nvm" ]]; then
|
||||||
|
|
||||||
|
# Set language configuration
|
||||||
|
echo '# Set locale configuration' >> ~/.profile
|
||||||
|
echo 'export LC_ALL=en_US.UTF-8' >> ~/.profile
|
||||||
|
echo 'export LANG=en_US.UTF-8' >> ~/.profile
|
||||||
|
echo 'export LANGUAGE=en_US.UTF-8' >> ~/.profile
|
||||||
|
echo "\n" >> ~/.profile
|
||||||
|
|
||||||
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
|
||||||
|
|
||||||
|
echo '# Node Version Manager' >> ~/.profile
|
||||||
|
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.profile
|
||||||
|
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.profile
|
||||||
|
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> ~/.profile
|
||||||
|
echo "\n" >> ~/.profile
|
||||||
|
echo 'autoload -U add-zsh-hook' >> ~/.profile
|
||||||
|
echo 'load-nvmrc() {' >> ~/.profile
|
||||||
|
echo ' local node_version="$(nvm version)"' >> ~/.profile
|
||||||
|
echo ' local nvmrc_path="$(nvm_find_nvmrc)"' >> ~/.profile
|
||||||
|
echo "\n" >> ~/.profile
|
||||||
|
echo ' if [ -n "$nvmrc_path" ]; then' >> ~/.profile
|
||||||
|
echo ' local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")' >> ~/.profile
|
||||||
|
echo "\n" >> ~/.profile
|
||||||
|
echo ' if [ "$nvmrc_node_version" = "N/A" ]; then' >> ~/.profile
|
||||||
|
echo ' nvm install' >> ~/.profile
|
||||||
|
echo ' elif [ "$nvmrc_node_version" != "$node_version" ]; then' >> ~/.profile
|
||||||
|
echo ' nvm use' >> ~/.profile
|
||||||
|
echo ' fi' >> ~/.profile
|
||||||
|
echo ' elif [ "$node_version" != "$(nvm version default)" ]; then' >> ~/.profile
|
||||||
|
echo ' echo "Reverting to nvm default version"' >> ~/.profile
|
||||||
|
echo ' nvm use default' >> ~/.profile
|
||||||
|
echo ' fi' >> ~/.profile
|
||||||
|
echo '}' >> ~/.profile
|
||||||
|
echo 'add-zsh-hook chpwd load-nvmrc' >> ~/.profile
|
||||||
|
echo 'load-nvmrc' >> ~/.profile
|
||||||
|
|
||||||
|
export NVM_DIR="$HOME/.nvm"
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Install Node.js #############################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo "Checking for Node.js... "
|
||||||
|
echo "***************************************************"
|
||||||
|
if ! node --version; then
|
||||||
|
nvm install stable
|
||||||
|
nvm alias default stable
|
||||||
|
nvm use default
|
||||||
|
else
|
||||||
|
echo 'OK'
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Ruby and Version Manager ####################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo 'Cheking for Ruby... '
|
||||||
|
echo "***************************************************"
|
||||||
|
if ! ruby -v; then
|
||||||
|
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
|
||||||
|
sudo apt install -y libxml2 libxml2-dev libxslt1-dev libpq-dev
|
||||||
|
\curl -sSL https://get.rvm.io | bash
|
||||||
|
source /home/vagrant/.rvm/scripts/rvm
|
||||||
|
rvm get head
|
||||||
|
rvm install ruby-2.3.6
|
||||||
|
rvm use ruby-2.3.6@global
|
||||||
|
gem update --system --no-ri --no-rdoc
|
||||||
|
gem update --no-ri --no-rdoc
|
||||||
|
rvm use ruby-2.3.6 --default
|
||||||
|
else
|
||||||
|
echo 'OK'
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Cleaning up #################################################################
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo 'Removing unused software... '
|
||||||
|
echo "***************************************************"
|
||||||
|
rvm cleanup all
|
||||||
|
sudo apt autoremove
|
36
provision/zsh_setup.sh
Executable file
36
provision/zsh_setup.sh
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo 'Updating system packages... '
|
||||||
|
echo "***************************************************"
|
||||||
|
sudo apt update && sudo apt upgrade -y
|
||||||
|
|
||||||
|
|
||||||
|
echo "***************************************************"
|
||||||
|
echo 'Checking Zsh installation... '
|
||||||
|
echo "***************************************************"
|
||||||
|
if ! dpkg -s zsh; then
|
||||||
|
# Install and set Zsh as shell
|
||||||
|
sudo apt install -y zsh
|
||||||
|
|
||||||
|
# Install Oh-My-Zsh!
|
||||||
|
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
|
||||||
|
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
||||||
|
|
||||||
|
# Change the Oh-My-Zsh! default configuration.
|
||||||
|
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="blinks"/g' ~/.zshrc
|
||||||
|
sed -i 's/# CASE_SENSITIVE="true"/CASE_SENSITIVE="true"/g' ~/.zshrc
|
||||||
|
sed -i 's/# COMPLETION_WAITING_DOTS="true"/COMPLETION_WAITING_DOTS="true"/g' ~/.zshrc
|
||||||
|
sed -i 's/# DISABLE_UNTRACKED_FILES_DIRTY="true"/DISABLE_UNTRACKED_FILES_DIRTY="true"/g' ~/.zshrc
|
||||||
|
sed -i 's/# HIST_STAMPS="mm/dd/yyyy"/HIST_STAMPS="yyyy-mm-dd"/g' ~/.zshrc
|
||||||
|
sed -i 's/plugins=(git)/plugins=(git dirhistory common-aliases command-not-found ruby)/g' ~/.zshrc
|
||||||
|
|
||||||
|
# Include .profile settings
|
||||||
|
echo ' ' >> ~/.zshrc
|
||||||
|
echo '# Include .profile settings' >> ~/.zshrc
|
||||||
|
echo 'source ~/.profile' >> ~/.zshrc
|
||||||
|
echo ' ' >> ~/.zshrc
|
||||||
|
|
||||||
|
# Change shell to Zsh for the vagrant user
|
||||||
|
sudo chsh -s /bin/zsh vagrant
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user