Merge pull request #62 from ross-p/feature-source-improvements
Source state improvements
This commit is contained in:
commit
b820500e2b
@ -41,9 +41,11 @@
|
|||||||
default_user: {{ nginx_map.default_user }}
|
default_user: {{ nginx_map.default_user }}
|
||||||
default_group: {{ nginx_map.default_group }}
|
default_group: {{ nginx_map.default_group }}
|
||||||
|
|
||||||
|
{% if nginx.get('init_conf_dirs', True) %}
|
||||||
{% for dir in ('sites-enabled', 'sites-available') %}
|
{% for dir in ('sites-enabled', 'sites-available') %}
|
||||||
/etc/nginx/{{ dir }}:
|
{{ conf_dir }}/{{ dir }}:
|
||||||
file.directory:
|
file.directory:
|
||||||
- user: root
|
- user: root
|
||||||
- group: root
|
- group: root
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
|
{% endif %}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
{% from "nginx/map.jinja" import nginx as nginx_map with context %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- nginx.common
|
- nginx.common
|
||||||
# Only upstart OR sysvinit should default to true.
|
{% if salt['pillar.get']('nginx:use_upstart', nginx_map['use_upstart']) %}
|
||||||
{% if pillar.get('nginx', {}).get('use_upstart', true) %}
|
|
||||||
- nginx.upstart
|
- nginx.upstart
|
||||||
{% elif pillar.get('nginx', {}).get('use_sysvinit', false) %}
|
{% elif salt['pillar.get']('nginx:use_sysvinit', nginx_map['use_sysvinit']) %}
|
||||||
- nginx.sysvinit
|
- nginx.sysvinit
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if pillar.get('nginx', {}).get('user_auth_enabled', true) %}
|
{% if pillar.get('nginx', {}).get('user_auth_enabled', true) %}
|
||||||
|
@ -5,7 +5,15 @@
|
|||||||
'default_user': 'www-data',
|
'default_user': 'www-data',
|
||||||
'default_group': 'www-data',
|
'default_group': 'www-data',
|
||||||
'disable_before_rename': False,
|
'disable_before_rename': False,
|
||||||
'old_init_disable': 'update-rc.d -f nginx remove'
|
'old_init_disable': 'update-rc.d -f nginx remove',
|
||||||
|
'use_upstart': True,
|
||||||
|
'use_sysvinit': False,
|
||||||
|
'home': '/var/www',
|
||||||
|
'conf_dir': '/etc/nginx',
|
||||||
|
'log_dir': '/var/log/nginx',
|
||||||
|
'sbin_dir': '/usr/sbin',
|
||||||
|
'install_prefix': '/usr/local/nginx',
|
||||||
|
'make_flags': '-j2'
|
||||||
},
|
},
|
||||||
'RedHat': {
|
'RedHat': {
|
||||||
'apache_utils': 'httpd-tools',
|
'apache_utils': 'httpd-tools',
|
||||||
@ -13,6 +21,14 @@
|
|||||||
'default_user': 'nginx',
|
'default_user': 'nginx',
|
||||||
'default_group': 'nginx',
|
'default_group': 'nginx',
|
||||||
'disable_before_rename': True,
|
'disable_before_rename': True,
|
||||||
'old_init_disable': 'chkconfig --del nginx'
|
'old_init_disable': 'chkconfig --del nginx',
|
||||||
|
'use_upstart': True,
|
||||||
|
'use_sysvinit': False,
|
||||||
|
'home': '/var/www',
|
||||||
|
'conf_dir': '/etc/nginx',
|
||||||
|
'log_dir': '/var/log/nginx',
|
||||||
|
'sbin_dir': '/usr/sbin',
|
||||||
|
'install_prefix': '/usr/local/nginx',
|
||||||
|
'make_flags': '-j2'
|
||||||
},
|
},
|
||||||
}, merge=salt['pillar.get']('nginx:lookup'), default='Debian') %}
|
}, merge=salt['pillar.get']('nginx:lookup'), default='Debian') %}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% from "nginx/map.jinja" import nginx with context %}
|
{% from "nginx/map.jinja" import nginx with context %}
|
||||||
{% set use_upstart = pillar.get('nginx', {}).get('use_upstart', true) %}
|
{% set use_upstart = salt['pillar.get']('nginx:use_upstart', nginx['use_upstart']) %}
|
||||||
{% if use_upstart %}
|
{% if use_upstart %}
|
||||||
nginx-old-init:
|
nginx-old-init:
|
||||||
file:
|
file:
|
||||||
|
@ -1,23 +1,27 @@
|
|||||||
|
{% from "nginx/map.jinja" import nginx as nginx_map with context %}
|
||||||
|
|
||||||
# Source currently requires package 'build-essential' which is Debian based.
|
# Source currently requires package 'build-essential' which is Debian based.
|
||||||
# Will not work with os_family RedHat! You have been warned.
|
# 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 version = nginx.get('version', '1.6.2') -%}
|
{% set version = nginx.get('version', '1.6.2') -%}
|
||||||
{% set checksum = nginx.get('checksum', 'sha256=b5608c2959d3e7ad09b20fc8f9e5bd4bc87b3bc8ba5936a513c04ed8f1391a18') -%}
|
{% set checksum = nginx.get('checksum', 'sha256=b5608c2959d3e7ad09b20fc8f9e5bd4bc87b3bc8ba5936a513c04ed8f1391a18') -%}
|
||||||
{% set home = nginx.get('home', '/var/www') -%}
|
{% set home = nginx.get('home', nginx_map['home']) -%}
|
||||||
{% set base_temp_dir = nginx.get('base_temp_dir', '/tmp') -%}
|
{% set base_temp_dir = nginx.get('base_temp_dir', '/tmp') -%}
|
||||||
{% set source = nginx.get('source_root', '/usr/local/src') -%}
|
{% set source = nginx.get('source_root', '/usr/local/src') -%}
|
||||||
|
|
||||||
{% set conf_dir = nginx.get('conf_dir', '/etc/nginx') -%}
|
{% 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', '/var/log/nginx') -%}
|
{% 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', '/var/run/nginx.pid') -%}
|
||||||
{% 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', '/usr/sbin') -%}
|
{% set sbin_dir = nginx.get('sbin_dir', nginx_map['sbin_dir']) -%}
|
||||||
|
|
||||||
{% set install_prefix = nginx.get('install_prefix', '/usr/local/nginx') -%}
|
{% set install_prefix = nginx.get('install_prefix', nginx_map['install_prefix']) -%}
|
||||||
{% set with_items = nginx.get('with', ['debug', 'http_dav_module', 'http_stub_status_module', 'pcre', 'ipv6']) -%}
|
{% set with_items = nginx.get('with', ['debug', 'http_dav_module', 'http_stub_status_module', 'pcre', 'ipv6']) -%}
|
||||||
{% set without_items = nginx.get('without', []) -%}
|
{% set without_items = nginx.get('without', []) -%}
|
||||||
{% set make_flags = nginx.get('make_flags', '-j2') -%}
|
{% set make_flags = nginx.get('make_flags', nginx_map['make_flags']) -%}
|
||||||
|
|
||||||
{% set nginx_package = source + '/nginx-' + version + '.tar.gz' -%}
|
{% set nginx_package = source + '/nginx-' + version + '.tar.gz' -%}
|
||||||
{% set nginx_source = source + "/nginx-" + version -%}
|
{% set nginx_source = source + "/nginx-" + version -%}
|
||||||
@ -35,22 +39,22 @@ include:
|
|||||||
|
|
||||||
nginx_group:
|
nginx_group:
|
||||||
group.present:
|
group.present:
|
||||||
- name: www-data
|
- name: {{ nginx_map.default_group }}
|
||||||
|
|
||||||
nginx_user:
|
nginx_user:
|
||||||
file.directory:
|
file.directory:
|
||||||
- name: {{ home }}
|
- name: {{ home }}
|
||||||
- user: www-data
|
- user: {{ nginx_map.default_user }}
|
||||||
- group: www-data
|
- group: {{ nginx_map.default_group }}
|
||||||
- mode: 0755
|
- mode: 0755
|
||||||
- require:
|
- require:
|
||||||
- user: nginx_user
|
- user: nginx_user
|
||||||
- group: nginx_group
|
- group: nginx_group
|
||||||
user.present:
|
user.present:
|
||||||
- name: www-data
|
- name: {{ nginx_map.default_user }}
|
||||||
- home: {{ home }}
|
- home: {{ home }}
|
||||||
- groups:
|
- groups:
|
||||||
- www-data
|
- {{ nginx_map.default_group }}
|
||||||
- require:
|
- require:
|
||||||
- group: nginx_group
|
- group: nginx_group
|
||||||
|
|
||||||
@ -69,11 +73,14 @@ get-nginx:
|
|||||||
- name: {{ nginx_package }}
|
- name: {{ nginx_package }}
|
||||||
- source: http://nginx.org/download/nginx-{{ version }}.tar.gz
|
- source: http://nginx.org/download/nginx-{{ version }}.tar.gz
|
||||||
- source_hash: {{ checksum }}
|
- source_hash: {{ checksum }}
|
||||||
|
- require:
|
||||||
|
- file: {{ nginx_modules_dir }}
|
||||||
cmd.wait:
|
cmd.wait:
|
||||||
- cwd: {{ source }}
|
- cwd: {{ source }}
|
||||||
- name: tar -zxf {{ nginx_package }}
|
- name: tar -zxf {{ nginx_package }}
|
||||||
- require:
|
- require:
|
||||||
- pkg: get-nginx
|
- pkg: get-nginx
|
||||||
|
- file: get-nginx
|
||||||
- watch:
|
- watch:
|
||||||
- file: get-nginx
|
- file: get-nginx
|
||||||
|
|
||||||
@ -110,10 +117,11 @@ nginx:
|
|||||||
cmd.wait:
|
cmd.wait:
|
||||||
- cwd: {{ nginx_source }}
|
- cwd: {{ nginx_source }}
|
||||||
- names:
|
- names:
|
||||||
- ./configure --conf-path={{ conf_dir }}/nginx.conf
|
- (
|
||||||
|
./configure --conf-path={{ conf_dir }}/nginx.conf
|
||||||
--sbin-path={{ sbin_dir }}/nginx
|
--sbin-path={{ sbin_dir }}/nginx
|
||||||
--user=www-data
|
--user={{ nginx_map.default_user }}
|
||||||
--group=www-data
|
--group={{ nginx_map.default_group }}
|
||||||
--prefix={{ install_prefix }}
|
--prefix={{ install_prefix }}
|
||||||
--http-log-path={{ log_dir }}/access.log
|
--http-log-path={{ log_dir }}/access.log
|
||||||
--error-log-path={{ log_dir }}/error.log
|
--error-log-path={{ log_dir }}/error.log
|
||||||
@ -135,16 +143,29 @@ nginx:
|
|||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
&& make {{ make_flags }}
|
&& make {{ make_flags }}
|
||||||
&& make install
|
&& make install
|
||||||
|
)
|
||||||
|
{#- If they want to silence the compiler output, then save it to file so we can reference it later if needed #}
|
||||||
|
{%- if nginx.get('silence_compiler', true) %}
|
||||||
|
> {{ nginx_source }}/build.out 2> {{ nginx_source }}/build.err;
|
||||||
|
{#- If the build process failed, write stderr to stderr and exit with the error code #}
|
||||||
|
r=$?;
|
||||||
|
if [ x$r != x0 ]; then
|
||||||
|
cat {{ nginx_source }}/build.err 1>&2; {#- copy err output to stderr #}
|
||||||
|
exit $r;
|
||||||
|
fi;
|
||||||
|
{% endif %}
|
||||||
- watch:
|
- watch:
|
||||||
- cmd: get-nginx
|
- cmd: get-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 %}
|
||||||
- watch_in:
|
- watch_in:
|
||||||
{% set logger_types = ('access', 'error') %}
|
{% set logger_types = ('access', 'error') %}
|
||||||
{% for log_type in logger_types %}
|
{% for log_type in logger_types %}
|
||||||
- service: nginx-logger-{{ log_type }}
|
- service: nginx-logger-{{ log_type }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
- require:
|
- require:
|
||||||
- cmd: get-nginx
|
- cmd: get-nginx
|
||||||
{% for name, module in nginx.get('modules', {}).items() -%}
|
{% for name, module in nginx.get('modules', {}).items() -%}
|
||||||
@ -166,7 +187,7 @@ nginx:
|
|||||||
service:
|
service:
|
||||||
- running
|
- running
|
||||||
- enable: True
|
- enable: True
|
||||||
- reload: True
|
- restart: True
|
||||||
- watch:
|
- watch:
|
||||||
- cmd: nginx
|
- cmd: nginx
|
||||||
- file: {{ conf_dir }}/nginx.conf
|
- file: {{ conf_dir }}/nginx.conf
|
||||||
|
@ -28,12 +28,6 @@ nginx-logger-{{ log_type }}:
|
|||||||
- file: nginx-logger-{{ log_type }}
|
- file: nginx-logger-{{ log_type }}
|
||||||
- require_in:
|
- require_in:
|
||||||
- service: nginx
|
- service: nginx
|
||||||
# Not supported in os_family other than Debian
|
|
||||||
{% if grains['os_family'] == 'Debian' %}
|
|
||||||
cmd:
|
|
||||||
- wait
|
|
||||||
- name: /usr/sbin/update-rc.d nginx-logger-{{ log_type }} defaults
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
/etc/logrotate.d/nginx:
|
/etc/logrotate.d/nginx:
|
||||||
|
Loading…
Reference in New Issue
Block a user