Browse Source

Merge pull request #158 from netmanagers/master

Add support to install phusion passenger in the `ng`
susefix
Niels Abspoel 7 years ago
parent
commit
9f5f966f7e
5 changed files with 163 additions and 12 deletions
  1. +9
    -0
      README.rst
  2. +27
    -0
      nginx/ng/map.jinja
  3. +41
    -0
      nginx/ng/passenger.sls
  4. +65
    -11
      nginx/ng/pkg.sls
  5. +21
    -1
      pillar.example

+ 9
- 0
README.rst View File

------------------- -------------------


Manages nginx virtual hosts files and binds them to service calls. Manages nginx virtual hosts files and binds them to service calls.

``nginx.ng.passenger``
----------------------

Installs and configures Phusion Passenger module for nginx. You need to enable
the upstream phusion passenger repository with `install_from_phusionpassenger: true`.
Nginx will also be installed from that repository, as it needs to be modified to
allow the passenger module to work.


+ 27
- 0
nginx/ng/map.jinja View File

'lookup': salt['grains.filter_by']({ 'lookup': salt['grains.filter_by']({
'Debian': { 'Debian': {
'package': 'nginx', 'package': 'nginx',
'passenger_package': 'passenger',
'service': 'nginx', 'service': 'nginx',
'webuser': 'www-data', 'webuser': 'www-data',
'conf_file': '/etc/nginx/nginx.conf', 'conf_file': '/etc/nginx/nginx.conf',
}, },
'CentOS': { 'CentOS': {
'package': 'nginx', 'package': 'nginx',
'passenger_package': 'passenger',
'service': 'nginx', 'service': 'nginx',
'webuser': 'nginx', 'webuser': 'nginx',
'conf_file': '/etc/nginx/nginx.conf', 'conf_file': '/etc/nginx/nginx.conf',
}, },
'RedHat': { 'RedHat': {
'package': 'nginx', 'package': 'nginx',
'passenger_package': 'passenger',
'service': 'nginx', 'service': 'nginx',
'webuser': 'nginx', 'webuser': 'nginx',
'conf_file': '/etc/nginx/nginx.conf', 'conf_file': '/etc/nginx/nginx.conf',
'rh_os_releasever': '$releasever', 'rh_os_releasever': '$releasever',
'gpg_check': False, 'gpg_check': False,
'gpg_key': 'http://nginx.org/keys/nginx_signing.key', 'gpg_key': 'http://nginx.org/keys/nginx_signing.key',
'passenger': {
'passenger_root': '/usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini',
'passenger_instance_registry_dir': ' /var/run/passenger-instreg',
'passenger_ruby': '/usr/bin/ruby',
},
}, },
'Suse': { 'Suse': {
'package': 'nginx', 'package': 'nginx',
'install_from_source': False, 'install_from_source': False,
'install_from_ppa': False, 'install_from_ppa': False,
'install_from_repo': False, 'install_from_repo': False,
'install_from_phusionpassenger': False,
'ppa_version': 'stable', 'ppa_version': 'stable',
'source_version': '1.10.0', 'source_version': '1.10.0',
'source_hash': '8ed647c3dd65bc4ced03b0e0f6bf9e633eff6b01bac772bcf97077d58bc2be4d', 'source_hash': '8ed647c3dd65bc4ced03b0e0f6bf9e633eff6b01bac772bcf97077d58bc2be4d',
}, },
'managed': {}, 'managed': {},
}, },
'passenger': {
'passenger_root': '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini',
'passenger_ruby': '/usr/bin/ruby',
},
}, merge=True) %} }, merge=True) %}


{% if 'user' not in nginx.server.config %} {% if 'user' not in nginx.server.config %}
})%} })%}
{% endif %} {% endif %}


{% if salt['grains.get']('os_family') == 'RedHat' %}
{% do nginx.passenger.update({
'passenger_root': '/usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini',
'passenger_instance_registry_dir': '/var/run/passenger-instreg',
})%}
{% if salt['grains.get']('osfinger') == 'CentOS-6' %}
{% do nginx.server.config.update({
'pid': '/var/run/nginx.pid',
})%}
{% do nginx.passenger.update({
'passenger_root': '/usr/lib/ruby/1.8/phusion_passenger/locations.ini',
})%}
{% endif %}
{% endif %}

+ 41
- 0
nginx/ng/passenger.sls View File

# nginx.ng.passenger
#
# Manages installation of passenger from repo.
# Requires install_from_phusionpassenger = True

{% from 'nginx/ng/map.jinja' import nginx, sls_block with context %}

{% if salt['grains.get']('os_family') in ['Debian', 'RedHat'] %}
include:
- nginx.ng.pkg
- nginx.ng.service

passenger_install:
pkg.installed:
- name: {{ nginx.lookup.passenger_package }}
- require:
- pkg: nginx_install
- require_in:
- service: nginx_service

/etc/nginx/passenger.conf:
file.absent:
- require:
- pkg: passenger_install

passenger_config:
file.managed:
{{ sls_block(nginx.server.opts) }}
- name: /etc/nginx/conf.d/passenger.conf
- source: salt://nginx/ng/files/nginx.conf
- template: jinja
- context:
config: {{ nginx.passenger|json() }}
- watch_in:
- service: nginx_service
- require_in:
- service: nginx_service
- require:
- file: /etc/nginx/passenger.conf
- pkg: passenger_install
{% endif %}

+ 65
- 11
nginx/ng/pkg.sls View File

# Manages installation of nginx from pkg. # Manages installation of nginx from pkg.


{% from 'nginx/ng/map.jinja' import nginx, sls_block with context %} {% from 'nginx/ng/map.jinja' import nginx, sls_block with context %}
{%- if nginx.install_from_repo %}
{% set from_official = true %}
{% set from_ppa = false %}
{% set from_phusionpassenger = false %}
{% elif nginx.install_from_ppa %}
{% set from_official = false %}
{% set from_ppa = true %}
{% set from_phusionpassenger = false %}
{% elif nginx.install_from_phusionpassenger %}
{% set from_official = false %}
{% set from_ppa = false %}
{% set from_phusionpassenger = true %}
{%- endif %}


nginx_install: nginx_install:
pkg.installed: pkg.installed:
- name: {{ nginx.lookup.package }} - name: {{ nginx.lookup.package }}


{% if salt['grains.get']('os_family') == 'Debian' %} {% if salt['grains.get']('os_family') == 'Debian' %}
{%- if nginx.install_from_repo %}
nginx-official-repo:
nginx_official_repo:
pkgrepo: pkgrepo:
{%- if from_official %}
- managed - managed
{%- else %}
- absent
{%- endif %}
- humanname: nginx apt repo - humanname: nginx apt repo
- name: deb http://nginx.org/packages/{{ grains['os'].lower() }}/ {{ grains['oscodename'] }} nginx - name: deb http://nginx.org/packages/{{ grains['os'].lower() }}/ {{ grains['oscodename'] }} nginx
- file: /etc/apt/sources.list.d/nginx-official-{{ grains['oscodename'] }}.list - file: /etc/apt/sources.list.d/nginx-official-{{ grains['oscodename'] }}.list
- pkg: nginx_install - pkg: nginx_install
- watch_in: - watch_in:
- pkg: nginx_install - pkg: nginx_install
{%- else %}
nginx_ppa_repo: nginx_ppa_repo:
pkgrepo: pkgrepo:
{%- if nginx.install_from_ppa %}
{%- if from_ppa %}
- managed - managed
{%- else %} {%- else %}
- absent - absent
- pkg: nginx_install - pkg: nginx_install
- watch_in: - watch_in:
- pkg: nginx_install - pkg: nginx_install
{%- endif %}

nginx_phusionpassenger_repo:
pkgrepo:
{%- if from_phusionpassenger %}
- managed
{%- else %}
- absent
{%- endif %}
- humanname: nginx phusionpassenger repo
- name: deb https://oss-binaries.phusionpassenger.com/apt/passenger {{ grains['oscodename'] }} main
- file: /etc/apt/sources.list.d/nginx-phusionpassenger-{{ grains['oscodename'] }}.list
- keyid: 561F9B9CAC40B2F7
- keyserver: keyserver.ubuntu.com
- require_in:
- pkg: nginx_install
- watch_in:
- pkg: nginx_install
{% endif %} {% endif %}


{% if salt['grains.get']('os_family') == 'Suse' %} {% if salt['grains.get']('os_family') == 'Suse' %}
nginx_zypp_repo: nginx_zypp_repo:
pkgrepo: pkgrepo:
{%- if nginx.install_from_repo %}
{%- if from_official %}
- managed - managed
{%- else %} {%- else %}
- absent - absent


{% if salt['grains.get']('os_family') == 'RedHat' %} {% if salt['grains.get']('os_family') == 'RedHat' %}
nginx_yum_repo: nginx_yum_repo:
{%- if nginx.install_from_repo %}
pkgrepo.managed:
{%- else %}
pkgrepo.absent:
{%- endif %}
pkgrepo:
{%- if from_official %}
- managed
{%- else %}
- absent
{%- endif %}
- name: nginx - name: nginx
- humanname: nginx repo - humanname: nginx repo
{%- if salt['grains.get']('os') == 'CentOS' %} {%- if salt['grains.get']('os') == 'CentOS' %}
- pkg: nginx_install - pkg: nginx_install
- watch_in: - watch_in:
- pkg: nginx_install - pkg: nginx_install

nginx_phusionpassenger_yum_repo:
pkgrepo:
{%- if from_phusionpassenger %}
- managed
{%- else %}
- absent
{%- endif %}
- name: passenger
- humanname: nginx phusionpassenger repo
- baseurl: 'https://oss-binaries.phusionpassenger.com/yum/passenger/el/$releasever/$basearch'
- repo_gpgcheck: 1
- gpgcheck: 0
- gpgkey: 'https://packagecloud.io/gpg.key'
- enabled: True
- sslverify: 1
- sslcacert: /etc/pki/tls/certs/ca-bundle.crt
- require_in:
- pkg: nginx_install
- watch_in:
- pkg: nginx_install
{% endif %} {% endif %}

+ 21
- 1
pillar.example View File



nginx: nginx:
ng: ng:
# The following three `install_from_` options are mutually exclusive. If none is used, the distro's provided
# package will be installed. If one of the `install_from` option is set to `True`, the state will
# make sure the other two repos are removed.

# Use the official's nginx repo binaries
install_from_repo: false

# Use Phusionpassenger's repo to install nginx and passenger binaries
# Debian, Centos, Ubuntu and Redhat are currently available
install_from_phusionpassenger: false

# PPA install # PPA install
install_from_ppa: True
install_from_ppa: false
# Set to 'stable', 'development' (mainline), 'community', or 'nightly' for each build accordingly ( https://launchpad.net/~nginx ) # Set to 'stable', 'development' (mainline), 'community', or 'nightly' for each build accordingly ( https://launchpad.net/~nginx )
ppa_version: 'stable' ppa_version: 'stable'


-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
(Your Private Key: www.example.com.key) (Your Private Key: www.example.com.key)
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----

# Passenger configuration
# Default passenger configuration is provided, and will be deployed in
# /etc/nginx/conf.d/passenger.conf
passenger:
passenger_root: /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
passenger_ruby: /usr/bin/ruby
passenger_instance_registry_dir: /var/run/passenger-instreg


Loading…
Cancel
Save