puppet-unicorn_systemd

Build Status Puppet Forge

Table of Contents

  1. Description
  2. Setup - The basics of getting started with unicorn_systemd
  3. Usage - Configuration options and additional functionality
  4. Reference - An under-the-hood peek at what the module is doing and how
  5. Limitations - OS compatibility, etc.
  6. Development - Guide for contributing to the module

Description

This module handles configuring and running unicorn service for systemd.

Setup

Beginning with unicorn_systemd

To configure the unicorn with default parameters, declare the unicorn_systemd class.

include ::unicorn_systemd

Usage

Configuring unicorn_systemd

class { 'unicorn_systemd':
  user              => 'app',
  working_directory => '/srv',
  listen_streams    => ['0.0.0.0:9000', '0.0.0.0:9001'],
  exec_start        => '/usr/local/bin/unicorn -E $RAILS_ENV /srv/sample.ru',
  environment       => 'RAILS_ENV=production'
}

Configuring modules from Hiera

---
unicorn_systemd::user: app
unicorn_systemd::working_directory: /srv
unicorn_systemd::listen_streams:
  - 0.0.0.0:9000
  - 0.0.0.0:9001
unicorn_systemd::exec_start: /usr/local/bin/unicorn -E $RAILS_ENV /srv/sample.ru
unicorn_systemd::environment:
  RAILS_ENV: production

Reference

Classes

Public Classes

Private Classes

  • unicorn_systemd::install: Installs unicorn initsystem file.
  • unicorn_systemd::service: Manages service.

Parameters

unicorn_systemd

  • ensure: Whether the unit files should exist. Valid options: present, absent, file. Default to present.
  • user: The user to execute the processes as. Valid options: a string containing a valid username. Default to 'nobody'.
  • group: The group to execute the processes as. Valid options: a string containing a valid groupname. Default to undef.
  • working_directory: The working directory for executed processes. Valid options: an absolute path. Default to undef.
  • listen_streams: The addresses to listen on for a stream. Valid options: an array of valid addresses. Default to ['127.0.0.1:8080', '/var/run/unicorn.sock'].
  • exec_start: The commands with their arguments that are executed for this service. Valid options: a string containing valid commands. Default to undef.
  • environment: The environment variables for executed processes. Valid options: a hash of key-value pairs. Default to {}.
  • service_ensure: Whether the service should be enabled. Valid options: 'running', 'true', 'stopped', or 'false'. Defaults to running.
  • service_enable: Whether the service should be enabled. Valid options: a boolean. Defaults to true.

Limitations

This module has been tested on:

  • RedHat Enterprise Linux 7
  • CentOS 7
  • Scientific Linux 7
  • Debian 8
  • Ubuntu 15.10
  • Ubuntu 16.04

Development

Running tests

The STNS puppet module contains tests for both rspec-puppet (unit tests) and beaker-rspec (acceptance tests) to verify functionality. For detailed information on using these tools, please see their respective documentation.

Testing quickstart

  • Unit tests:
$ bundle install
$ bundle exec rake
  • Acceptance tests:
# Set your DOCKER_HOST variable
$ eval "$(docker-machine env default)"

# Run beaker acceptance tests
$ BEAKER_set=centos7 bundle exec rake beaker