Add support for building from source with os_family=RedHat

This commit is contained in:
Aline Freitas 2015-08-13 23:40:55 -03:00
parent b068bc6a9d
commit da1405c5e7
3 changed files with 28 additions and 9 deletions

View File

@ -1,6 +1,11 @@
{% set nginx = salt['grains.filter_by']({ {% set nginx = salt['grains.filter_by']({
'Debian': { 'Debian': {
'apache_utils': 'apache2-utils', 'apache_utils': 'apache2-utils',
'group_action': 'pkg.installed',
'group_pkg': 'build-essential',
'libpcre_dev': 'libpcre3-dev',
'libssl_dev': 'libssl-dev',
'pid_path': '/var/run/nginx.pid',
'package': 'nginx-full', 'package': 'nginx-full',
'default_user': 'www-data', 'default_user': 'www-data',
'default_group': 'www-data', 'default_group': 'www-data',
@ -17,6 +22,11 @@
}, },
'RedHat': { 'RedHat': {
'apache_utils': 'httpd-tools', 'apache_utils': 'httpd-tools',
'group_action': 'pkg.group_install',
'group_pkg': 'Development Tools',
'libpcre_dev': 'pcre-devel',
'libssl_dev': 'openssl-devel',
'pid_path': '/run/nginx.pid',
'package': 'nginx', 'package': 'nginx',
'default_user': 'nginx', 'default_user': 'nginx',
'default_group': 'nginx', 'default_group': 'nginx',
@ -31,4 +41,4 @@
'install_prefix': '/usr/local/nginx', 'install_prefix': '/usr/local/nginx',
'make_flags': '-j2' 'make_flags': '-j2'
}, },
}, merge=salt['pillar.get']('nginx:lookup'), default='Debian') %} }, grain='os_family', merge=salt['pillar.get']('nginx:lookup'), default='Debian') %}

View File

@ -24,7 +24,7 @@
'vhost_available': '/etc/nginx/conf.d', 'vhost_available': '/etc/nginx/conf.d',
'vhost_enabled': '/etc/nginx/conf.d', 'vhost_enabled': '/etc/nginx/conf.d',
'vhost_use_symlink': False, 'vhost_use_symlink': False,
'pid_file': '/var/run/nginx.pid', 'pid_file': '/run/nginx.pid',
'rh_os_releasever': '$releasever', 'rh_os_releasever': '$releasever',
}, },
'Suse': { 'Suse': {

View File

@ -1,8 +1,5 @@
{% from "nginx/map.jinja" import nginx as nginx_map with context %} {% from "nginx/map.jinja" import nginx as nginx_map with context %}
# Source currently requires package 'build-essential' which is Debian based.
# Will not work with os_family RedHat!
# TODO- Someone with a RedHat system please update this to work on RedHat
{% set nginx = pillar.get('nginx', {}) -%} {% set nginx = pillar.get('nginx', {}) -%}
{% set use_sysvinit = nginx.get('use_sysvinit', nginx_map['use_sysvinit']) %} {% set use_sysvinit = nginx.get('use_sysvinit', nginx_map['use_sysvinit']) %}
{% set version = nginx.get('version', '1.6.2') -%} {% set version = nginx.get('version', '1.6.2') -%}
@ -15,7 +12,7 @@
{% set conf_dir = nginx.get('conf_dir', nginx_map['conf_dir']) -%} {% set conf_dir = nginx.get('conf_dir', nginx_map['conf_dir']) -%}
{% set conf_only = nginx.get('conf_only', false) -%} {% set conf_only = nginx.get('conf_only', false) -%}
{% set log_dir = nginx.get('log_dir', nginx_map['log_dir']) -%} {% set log_dir = nginx.get('log_dir', nginx_map['log_dir']) -%}
{% set pid_path = nginx.get('pid_path', '/var/run/nginx.pid') -%} {% set pid_path = nginx.get('pid_path', nginx_map['pid_path']) -%}
{% set lock_path = nginx.get('lock_path', '/var/lock/nginx.lock') -%} {% set lock_path = nginx.get('lock_path', '/var/lock/nginx.lock') -%}
{% set sbin_dir = nginx.get('sbin_dir', nginx_map['sbin_dir']) -%} {% set sbin_dir = nginx.get('sbin_dir', nginx_map['sbin_dir']) -%}
@ -67,12 +64,22 @@ nginx_user:
- directory - directory
- makedirs: True - makedirs: True
get-build-tools:
{% if salt['pkg.version']('salt') <= '2015.8.0' and grains['os_family'] == 'RedHat' %}
module.run:
- name: pkg.group_install
- m_name: {{ nginx_map.group_pkg }}
{% else %}
{{ nginx_map.group_action }}:
- name: {{ nginx_map.group_pkg }}
{% endif %}
get-nginx: get-nginx:
pkg.installed: pkg.installed:
- names: - names:
- libpcre3-dev - {{ nginx_map.libpcre_dev }}
- build-essential - {{ nginx_map.libssl_dev }}
- libssl-dev
file.managed: file.managed:
- name: {{ nginx_package }} - name: {{ nginx_package }}
- source: {{ tarball_url }} - source: {{ tarball_url }}
@ -218,6 +225,7 @@ nginx:
{% for name, module in nginx.get('modules', {}).items() -%} {% for name, module in nginx.get('modules', {}).items() -%}
- file: get-nginx-{{name}} - file: get-nginx-{{name}}
{% endfor %} {% endfor %}
{% if use_sysvinit %}
file: file:
- managed - managed
- template: jinja - template: jinja
@ -230,6 +238,7 @@ nginx:
service_name: {{ service_name }} service_name: {{ service_name }}
sbin_dir: {{ sbin_dir }} sbin_dir: {{ sbin_dir }}
pid_path: {{ pid_path }} pid_path: {{ pid_path }}
{% endif %}
service: service:
{% if service_enable %} {% if service_enable %}
- running - running