From 2cfda9a9305e8455609d90d8fbd10509a6cd0dc9 Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Tue, 8 Mar 2016 19:37:39 +0100 Subject: [PATCH] Fix check HTTP2 on FreeBSD (multi-OS code) --- tasks/prepare.yml | 12 ++++++++++-- templates/etc/nginx/sites-available/_base.j2 | 2 +- tests/includes/pre_Debian.yml | 1 + tests/includes/pre_FreeBSD.yml | 2 ++ tests/test.yml | 13 ++++++------- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tasks/prepare.yml b/tasks/prepare.yml index a54f255..45e87fd 100644 --- a/tasks/prepare.yml +++ b/tasks/prepare.yml @@ -2,14 +2,22 @@ - name: SHELL | Get Nginx version shell: nginx -v 2>&1 | sed -r 's#.*/##;' | cut -d ' ' -f 1 + args: + executable: /bin/sh register: nginx_version changed_when: false - name: SHELL | Get module list - shell: nginx -V 2>&1 | tr -- - '\n' | grep -A 1 with | grep _module | sed -r 's/_module\s*$//g' |sort - register: nginx_modules + shell: nginx -V 2>&1 | tr -- - '\n' | grep -A 1 with | grep _module | sed 's/_module[[:space:]]*//g' | sort + args: + executable: /bin/sh + register: shell_modules changed_when: false +- name: SET_FACT | Save modules + set_fact: + nginx_modules: "{{ shell_modules.stdout_lines }}" + - name: FILE | Create folders file: dest={{ item }} owner=root mode=0755 state=directory with_items: "{{ nginx_dirs }}" diff --git a/templates/etc/nginx/sites-available/_base.j2 b/templates/etc/nginx/sites-available/_base.j2 index 354ef6b..915793a 100644 --- a/templates/etc/nginx/sites-available/_base.j2 +++ b/templates/etc/nginx/sites-available/_base.j2 @@ -30,7 +30,7 @@ server { {% endif %} {% if 'https' in __proto %} {% for port in __listen_ssl %} - listen {{ port }}{% if nginx_default_vhost_ssl == __main_name %} default_server{% endif %} ssl{% if nginx_auto_config_httpv2 and 'http_v2' in nginx_modules.stdout_lines %} http2{% endif %}; + listen {{ port }}{% if nginx_default_vhost_ssl == __main_name %} default_server{% endif %} ssl{% if nginx_auto_config_httpv2 and 'http_v2' in nginx_modules %} http2{% endif %}; {% endfor %} {{ ssl(item.ssl_name) }} include {{ nginx_helper_dir + '/ssl-' + item.ssl_template | default('strong') }}; diff --git a/tests/includes/pre_Debian.yml b/tests/includes/pre_Debian.yml index 17e6fb4..0898923 100644 --- a/tests/includes/pre_Debian.yml +++ b/tests/includes/pre_Debian.yml @@ -9,6 +9,7 @@ - php5-fpm - curl - fcgiwrap + - nghttp2 - name: SERVICE | Force start services service: name={{ item }} state=started diff --git a/tests/includes/pre_FreeBSD.yml b/tests/includes/pre_FreeBSD.yml index 6555bf1..e86bdb0 100644 --- a/tests/includes/pre_FreeBSD.yml +++ b/tests/includes/pre_FreeBSD.yml @@ -2,6 +2,7 @@ - name: SET_FACT | FreeBSD web user set_fact: + nginx_pkgng_package: 'nginx-devel' nginx_user: 'www' nginx_php_sockets: - host: '127.0.0.1' @@ -13,6 +14,7 @@ - php56 - curl - fcgiwrap + - nghttp2 - name: SERVICE | Force start services service: name={{ item }} state=started enabled=yes diff --git a/tests/test.yml b/tests/test.yml index 4ba11fe..f341f71 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -328,10 +328,9 @@ # -------------------------------- # Check HTTP2 # -------------------------------- - - block: - - name: APT | Install nghttp2 - apt: pkg=nghttp2 state=present - - name: SHELL | Check HTTP2 - shell: nghttp -nv https://localhost 2> /dev/null | grep -q h2 - changed_when: false - when: nginx_auto_config_httpv2 and 'http_v2' in nginx_modules.stdout_lines + - name: SHELL | Check HTTP2 + shell: nghttp -nv https://localhost 2> /dev/null | grep -q h2 + args: + executable: /bin/sh + changed_when: false + when: nginx_auto_config_httpv2 and 'http_v2' in nginx_modules