Separate NGINX install from source and package states
This commit is contained in:
parent
874719e49e
commit
5c68f12801
@ -5,8 +5,9 @@
|
|||||||
{% 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_source %}
|
{% if nginx.install_from_source %}
|
||||||
/var/log/nginx:
|
nginx_log_directory:
|
||||||
file.directory
|
file.directory:
|
||||||
|
- name: /var/log/nginx
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
nginx_config:
|
nginx_config:
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
'source_hash': '8ed647c3dd65bc4ced03b0e0f6bf9e633eff6b01bac772bcf97077d58bc2be4d',
|
'source_hash': '8ed647c3dd65bc4ced03b0e0f6bf9e633eff6b01bac772bcf97077d58bc2be4d',
|
||||||
'source': {
|
'source': {
|
||||||
'opts': {},
|
'opts': {},
|
||||||
|
'modules': {}
|
||||||
},
|
},
|
||||||
'package': {
|
'package': {
|
||||||
'opts': {},
|
'opts': {},
|
||||||
|
@ -1,75 +1,13 @@
|
|||||||
# nginx.ng.install
|
# nginx.ng.pkg
|
||||||
#
|
#
|
||||||
# Manages installation of nginx.
|
# 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_source %}
|
|
||||||
nginx_build_dep:
|
|
||||||
{% if salt['grains.get']('os_family') == 'Debian' %}
|
|
||||||
cmd.run:
|
|
||||||
- name: apt-get -y build-dep nginx
|
|
||||||
{% elif salt['grains.get']('os_family') == 'RedHat' %}
|
|
||||||
cmd.run:
|
|
||||||
- name: yum-builddep -y nginx
|
|
||||||
{% else %}
|
|
||||||
## install build deps for other distros
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
nginx_download:
|
|
||||||
archive.extracted:
|
|
||||||
- name: /tmp/
|
|
||||||
- source: http://nginx.org/download/nginx-{{ nginx.source_version }}.tar.gz
|
|
||||||
- source_hash: sha256={{ nginx.source_hash }}
|
|
||||||
- archive_format: tar
|
|
||||||
- if_missing: /usr/sbin/nginx-{{ nginx.source_version }}
|
|
||||||
- require:
|
|
||||||
- cmd: nginx_build_dep
|
|
||||||
- onchanges:
|
|
||||||
- cmd: nginx_build_dep
|
|
||||||
|
|
||||||
nginx_configure:
|
|
||||||
cmd.run:
|
|
||||||
- name: ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf {{ nginx.source.opts | join(' ') }}
|
|
||||||
- cwd: /tmp/nginx-{{ nginx.source_version }}
|
|
||||||
- require:
|
|
||||||
- archive: nginx_download
|
|
||||||
- onchanges:
|
|
||||||
- archive: nginx_download
|
|
||||||
|
|
||||||
nginx_compile:
|
|
||||||
cmd.run:
|
|
||||||
- name: make
|
|
||||||
- cwd: /tmp/nginx-{{ nginx.source_version }}
|
|
||||||
- require:
|
|
||||||
- cmd: nginx_configure
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
nginx_install:
|
nginx_install:
|
||||||
{% if nginx.install_from_source %}
|
|
||||||
cmd.run:
|
|
||||||
- name: make install
|
|
||||||
- cwd: /tmp/nginx-{{ nginx.source_version }}
|
|
||||||
- require:
|
|
||||||
- cmd: nginx_compile
|
|
||||||
- onchanges:
|
|
||||||
- cmd: nginx_compile
|
|
||||||
{% else %}
|
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
{{ sls_block(nginx.package.opts) }}
|
{{ sls_block(nginx.package.opts) }}
|
||||||
- name: {{ nginx.lookup.package }}
|
- name: {{ nginx.lookup.package }}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if nginx.install_from_source %}
|
|
||||||
nginx_link:
|
|
||||||
file.copy:
|
|
||||||
- name: /usr/sbin/nginx-{{ nginx.source_version }}
|
|
||||||
- source: /usr/sbin/nginx
|
|
||||||
- require:
|
|
||||||
- cmd: nginx_install
|
|
||||||
- onchanges:
|
|
||||||
- cmd: nginx_install
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if salt['grains.get']('os_family') == 'Debian' %}
|
{% if salt['grains.get']('os_family') == 'Debian' %}
|
||||||
{%- if nginx.install_from_repo %}
|
{%- if nginx.install_from_repo %}
|
@ -6,11 +6,16 @@
|
|||||||
{% set service_function = {True:'running', False:'dead'}.get(nginx.service.enable) %}
|
{% set service_function = {True:'running', False:'dead'}.get(nginx.service.enable) %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- nginx.ng.install
|
{% if nginx.install_from_source %}
|
||||||
|
- nginx.ng.src
|
||||||
|
{% else %}
|
||||||
|
- nginx.ng.pkg
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if nginx.install_from_source %}
|
{% if nginx.install_from_source %}
|
||||||
/lib/systemd/system/nginx.service:
|
nginx_systemd_service_file:
|
||||||
file.managed:
|
file.managed:
|
||||||
|
- name: /lib/systemd/system/nginx.service
|
||||||
- source: salt://nginx/ng/files/nginx.service
|
- source: salt://nginx/ng/files/nginx.service
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@ -20,7 +25,11 @@ nginx_service:
|
|||||||
- name: {{ nginx.lookup.service }}
|
- name: {{ nginx.lookup.service }}
|
||||||
- enable: {{ nginx.service.enable }}
|
- enable: {{ nginx.service.enable }}
|
||||||
- require:
|
- require:
|
||||||
- sls: nginx.ng.install
|
{% if nginx.install_from_source %}
|
||||||
|
- sls: nginx.ng.src
|
||||||
|
{% else %}
|
||||||
|
- sls: nginx.ng.pkg
|
||||||
|
{% endif %}
|
||||||
- watch:
|
- watch:
|
||||||
{% if nginx.install_from_source %}
|
{% if nginx.install_from_source %}
|
||||||
- cmd: nginx_install
|
- cmd: nginx_install
|
||||||
|
62
nginx/ng/src.sls
Normal file
62
nginx/ng/src.sls
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# nginx.ng.src
|
||||||
|
#
|
||||||
|
# Manages installation of nginx from source.
|
||||||
|
|
||||||
|
{% from 'nginx/ng/map.jinja' import nginx, sls_block with context %}
|
||||||
|
|
||||||
|
nginx_build_dep:
|
||||||
|
{% if salt['grains.get']('os_family') == 'Debian' %}
|
||||||
|
cmd.run:
|
||||||
|
- name: apt-get -y build-dep nginx
|
||||||
|
{% elif salt['grains.get']('os_family') == 'RedHat' %}
|
||||||
|
cmd.run:
|
||||||
|
- name: yum-builddep -y nginx
|
||||||
|
{% else %}
|
||||||
|
## install build deps for other distros
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
nginx_download:
|
||||||
|
archive.extracted:
|
||||||
|
- name: /tmp/
|
||||||
|
- source: http://nginx.org/download/nginx-{{ nginx.source_version }}.tar.gz
|
||||||
|
- source_hash: sha256={{ nginx.source_hash }}
|
||||||
|
- archive_format: tar
|
||||||
|
- if_missing: /usr/sbin/nginx-{{ nginx.source_version }}
|
||||||
|
- require:
|
||||||
|
- cmd: nginx_build_dep
|
||||||
|
- onchanges:
|
||||||
|
- cmd: nginx_build_dep
|
||||||
|
|
||||||
|
nginx_configure:
|
||||||
|
cmd.run:
|
||||||
|
- name: ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf {{ nginx.source.opts | join(' ') }}
|
||||||
|
- cwd: /tmp/nginx-{{ nginx.source_version }}
|
||||||
|
- require:
|
||||||
|
- archive: nginx_download
|
||||||
|
- onchanges:
|
||||||
|
- archive: nginx_download
|
||||||
|
|
||||||
|
nginx_compile:
|
||||||
|
cmd.run:
|
||||||
|
- name: make
|
||||||
|
- cwd: /tmp/nginx-{{ nginx.source_version }}
|
||||||
|
- require:
|
||||||
|
- cmd: nginx_configure
|
||||||
|
|
||||||
|
nginx_install:
|
||||||
|
cmd.run:
|
||||||
|
- name: make install
|
||||||
|
- cwd: /tmp/nginx-{{ nginx.source_version }}
|
||||||
|
- require:
|
||||||
|
- cmd: nginx_compile
|
||||||
|
- onchanges:
|
||||||
|
- cmd: nginx_compile
|
||||||
|
|
||||||
|
nginx_link:
|
||||||
|
file.copy:
|
||||||
|
- name: /usr/sbin/nginx-{{ nginx.source_version }}
|
||||||
|
- source: /usr/sbin/nginx
|
||||||
|
- require:
|
||||||
|
- cmd: nginx_install
|
||||||
|
- onchanges:
|
||||||
|
- cmd: nginx_install
|
Loading…
Reference in New Issue
Block a user