Skip to content

Instantly share code, notes, and snippets.

@avtar
Created October 8, 2015 23:30
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 avtar/4392fe45af06f1d05ec1 to your computer and use it in GitHub Desktop.
Save avtar/4392fe45af06f1d05ec1 to your computer and use it in GitHub Desktop.
- src: https://github.com/idi-ops/ansible-facts
name: facts
- src: https://github.com/avtar/ansible-nodejs
version: remotes/origin/vboxsf-changes
name: nodejs
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
ansible_vars = YAML.load_file('provisioning/vars.yml')
# By default this VM will use 1 processor core and 1GB of RAM. The 'VM_CPUS' and
# "VM_RAM" environment variables can be used to change that behaviour.
cpus = ENV["VM_CPUS"] || 1
ram = ENV["VM_RAM"] || 1048
# If 'nodejs_app_tcp_port' is defined in vars.yml then use that port. Otherwise
# check for 'VM_HOST_TCP_PORT' or 'VM_GUEST_TCP_PORT' environment variables.
# Failing that use defaults provided in this file.
host_tcp_port = ansible_vars["nodejs_app_tcp_port"] || ENV["VM_HOST_TCP_PORT"] || 8081
guest_tcp_port = ansible_vars["nodejs_app_tcp_port"] || ENV["VM_GUEST_TCP_PORT"] || 8081
app_name = ansible_vars["nodejs_app_name"]
Vagrant.configure(2) do |config|
config.vm.box = "inclusivedesign/centos7"
# Your working directory will be synced to /home/vagrant/sync in the VM.
config.vm.synced_folder ".", "/home/vagrant/sync"
# List additional directories to sync to the VM in your "Vagrantfile.local" file
# using the following format:
# config.vm.synced_folder "../path/on/your/host/os/your-project", "/home/vagrant/sync/your-project"
# Port forwarding takes place here. The 'guest' port is used inside the VM
# whereas the 'host' port is used by your host operating system.
config.vm.network "forwarded_port", guest: guest_tcp_port, host: host_tcp_port, protocol: 'tcp',
auto_correct: true
# Port 19531 is needed so logs can be viewed using systemd-journal-gateway
config.vm.network "forwarded_port", guest: 19531, host: 19531, auto_correct: true
config.vm.hostname = app_name
config.vm.provider :virtualbox do |vm|
vm.customize ["modifyvm", :id, "--memory", ram]
vm.customize ["modifyvm", :id, "--cpus", cpus]
end
# The ansible-galaxy command assumes a git client is available in the VM, the
# inclusivedesign/centos7 Vagrant box includes one.
config.vm.provision "shell", inline: <<-SHELL
sudo ansible-galaxy install -fr /home/vagrant/sync/provisioning/requirements.yml
sudo PYTHONUNBUFFERED=1 ansible-playbook /home/vagrant/sync/provisioning/playbook.yml --tags="install,configure,deploy"
SHELL
# 'Vagrantfile.local' should be excluded from version control.
if File.exist? "Vagrantfile.local"
instance_eval File.read("Vagrantfile.local"), "Vagrantfile.local"
end
# http://serverfault.com/a/725051
config.vm.provision "shell", inline: "sudo systemctl restart #{app_name}.service",
run: "always"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment