Ansible Node.js Site Role
This role will install NVM and use that to setup a given version of Node.js. It will create an Nginx site running that node executable through Phusion Passenger.
Requirements
Installing NVM requires that Git already be installed on your server. But come on, you already did that, right?
This role takes advantage of Linux filesystem ACLs and a group called "web-admin" for granting access to particular directories. You can either configure those steps manually or install the bbatsche.Base
role.
Role Variables
domain
— Site domain to be created.nvm_version
— Version of NVM to be installed. Default is "v0.33.8".node_version
— Version of Node.js to be installed. Default is "v8.9.4".copy_appjs
— Whether to copy a stub app.js file to the site, useful for testing. Default is no.http_root
— Directory all site directories will be created under. Default is "/srv/http".nvm_root
— Directory to install NVM and its support files. Default is "/usr/local/nvm"
Dependencies
This role depends on bbatsche.Nginx. You must install that role first using:
ansible-galaxy install bbatsche.Nginx
Example Playbook
- hosts: servers
roles:
- { role: bbatsche.Node, domain: my-node-site.dev }
License
MIT
Testing
Included with this role is a set of specs for testing each task individually or as a whole. To run these tests you will first need to have Vagrant and VirtualBox installed. The spec files are written using Serverspec so you will need Ruby and Bundler.
To run the full suite of specs:
$ gem install bundler
$ bundle install
$ rake
The spec suite will target both Ubuntu Trusty Tahr (14.04) and Xenial Xerus (16.04).
To see the available rake tasks (and specs):
$ rake -T
These specs are not meant to test for idempotence. They are meant to check that the specified tasks perform their expected steps. Idempotency is tested independently via integration testing.