diff --git a/nginx/source.sls b/nginx/source.sls index b4da976..ea0eade 100644 --- a/nginx/source.sls +++ b/nginx/source.sls @@ -6,6 +6,7 @@ {% 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 tarball_url = nginx.get('tarball_url', 'http://nginx.org/download/nginx-' + version + '.tar.gz') -%} {% set checksum = nginx.get('checksum', 'sha256=b5608c2959d3e7ad09b20fc8f9e5bd4bc87b3bc8ba5936a513c04ed8f1391a18') -%} {% set home = nginx.get('home', nginx_map['home']) -%} {% set base_temp_dir = nginx.get('base_temp_dir', '/tmp') -%} @@ -71,7 +72,7 @@ get-nginx: - libssl-dev file.managed: - name: {{ nginx_package }} - - source: http://nginx.org/download/nginx-{{ version }}.tar.gz + - source: {{ tarball_url }} - source_hash: {{ checksum }} - require: - file: {{ nginx_modules_dir }} @@ -113,6 +114,42 @@ get-ngx_devel_kit: - file: get-ngx_devel_kit {% endif %} +nginx-source-modified: + cmd.run: + - cwd: {{ nginx_source }} + - stateful: True + - names: + - m=$(find . \! -name "build.*" -newer {{ sbin_dir }}/nginx -print -quit); + r=$?; + if [ x$r != x0 ]; then + echo "changed=yes comment='binary file does not exist or other find error'"; + exit 0; + fi; + if [ x$m != "x" ]; then + echo "changed=yes comment='source files are newer than binary'"; + exit 0; + fi; + echo "changed=no comment='source files are older than binary'" + +{% for name, module in nginx.get('modules', {}).items() -%} +nginx-module-modified-{{name}}: + cmd.run: + - cwd: {{ nginx_modules_dir }}/{{name}} + - stateful: True + - names: + - m=$(find . \! -name "build.*" -newer {{ sbin_dir }}/nginx -print -quit); + r=$?; + if [ x$r != x0 ]; then + echo "changed=yes comment='binary file does not exist or other find error'"; + exit 0; + fi; + if [ x$m != "x" ]; then + echo "changed=yes comment='module source files are newer than binary'"; + exit 0; + fi; + echo "changed=no comment='module source files are older than binary'" +{% endfor -%} + nginx: cmd.wait: - cwd: {{ nginx_source }} @@ -156,7 +193,9 @@ nginx: {% endif %} - watch: - cmd: get-nginx + - cmd: nginx-source-modified {% for name, module in nginx.get('modules', {}).items() -%} + - cmd: nginx-module-modified-{{name}} - file: get-nginx-{{name}} {% endfor %} {% if use_sysvinit %}