Ruby
Ansible Ruby Site Role
This role will install Rbenv and use that to install a given version of Ruby. It will create an Nginx site that runs ruby through Phusion Passenger.
Requirements
Installing Rbenv requires Git to be installed on the server. But of course, 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.ruby_version
— Version of Ruby to install. Default is "2.3.1"rbenv_version
— Version of Rbenv to install. Default is "v1.0.0"ruby_build_version
— Version of ruby-build plugin to install. Default is "v20160426"default_gems_version
— Version of default-gems plugin to install. Default is a Git SHA: "4f68eae"rbenv_vars_version
— Version of rbenv-vars plugin to install Default is "v1.2.0"binstubs_version
— Version of binstubs plugin to install. Default is "v1.4"copy_configru
— Whether to copy a stub config.ru file to the site, useful for testing. Default is nohttp_root
— Directory all site directories will be created under. Default is "/srv/http".rbenv_root
— Directory to install Rbenv and its support files. Default is "/usr/local/rbenv"
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.Ruby, 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 Ubuntu Trusty Tahr (14.04), Xenial Xerus (16.04), and Bionic Bever (18.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.