Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds vagrant box support for testing with old versions of Node.js
- Loading branch information
1 parent
4c3dcc4
commit eac22db
Showing
5 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
node_modules | ||
bower_components | ||
.config | ||
.npm | ||
.npmrc | ||
.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
require 'yaml' | ||
|
||
ansible_vars = YAML.load_file('provisioning/vars.yml') | ||
|
||
app_name = ansible_vars["nodejs_app_name"] | ||
|
||
app_directory = ansible_vars["nodejs_app_install_dir"] | ||
|
||
# Check for the existence of 'VM_HOST_TCP_PORT' or 'VM_GUEST_TCP_PORT' | ||
# environment variables. Otherwise if 'nodejs_app_tcp_port' is defined | ||
# in vars.yml then use that port. Failing that use defaults provided | ||
# in this file. | ||
host_tcp_port = ENV["VM_HOST_TCP_PORT"] || ansible_vars["nodejs_app_tcp_port"] || 8080 | ||
guest_tcp_port = ENV["VM_GUEST_TCP_PORT"] || ansible_vars["nodejs_app_tcp_port"] || 8080 | ||
|
||
# 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 | ||
|
||
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 ".", "#{app_directory}" | ||
|
||
# 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, protocol: "tcp", | ||
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 #{app_directory}/provisioning/requirements.yml | ||
sudo PYTHONUNBUFFERED=1 ansible-playbook #{app_directory}/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" | ||
|
||
config.vm.provision "shell", inline: "sudo systemctl restart systemd-journal-gatewayd.service", | ||
run: "always" | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- hosts: localhost | ||
user: root | ||
|
||
vars_files: | ||
- vars.yml | ||
|
||
roles: | ||
- facts | ||
- nodejs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- src: https://github.com/idi-ops/ansible-facts | ||
name: facts | ||
|
||
- src: https://github.com/idi-ops/ansible-nodejs | ||
name: nodejs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
# Please refer to https://github.com/idi-ops/ansible-nodejs/blob/master/defaults/main.yml | ||
# for additional documentation related to these variables | ||
|
||
# A hyphenated string representing the application's name. | ||
nodejs_app_name: oscjs-tests | ||
|
||
# A boolean stating whether the application's Git repository should be cloned or | ||
# not. An example scenario where you may want to set this to 'false' would be a | ||
# Vagrant project used for development where the application's source code might | ||
# already be present on local storage. | ||
nodejs_app_git_clone: false | ||
|
||
# The absolute file system path where either the application directory or the | ||
# Git working directory will be located. | ||
nodejs_app_install_dir: /home/vagrant | ||
|
||
# A YAML list of commands that will be executed in order within the application's | ||
# Git working directory. | ||
nodejs_app_commands: | ||
- npm install | ||
|
||
# The application script passed as an argument to the Node.js binary. If this | ||
# isn't set then the application won't start. | ||
nodejs_app_start_script: tests/node-all-tests.js | ||
|
||
# Enabling this will manage the application using https://github.com/remy/nodemon | ||
# so that Node process is restarted when file system changes are detected. This | ||
# will only work if 'nodejs_app_start_script' is set. | ||
nodejs_app_dev_env: true | ||
|
||
# A YAML list of RPM packages that the application requires. | ||
# nodejs_app_rpm_packages: | ||
# - nodejs-grunt-cli | ||
|
||
# A TCP port used by the application. | ||
# Example: 8080 | ||
# nodejs_app_tcp_port: '' |