From 71de789262a7925f9b8ea8b14d573439c9d97a04 Mon Sep 17 00:00:00 2001 From: poll0rz Date: Sun, 18 Oct 2015 02:24:30 +0200 Subject: [PATCH] Install latest Nginx version from official repos If you use default Debian or Ubuntu repos, you'll get Nginx 1.4.x, which is really outdated and has lots of security bugs. It's better if you configure Nginx official repo and install version >= 1.8.x Hope this helps! --- nginx/tasks/setup-nginx.yml | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/nginx/tasks/setup-nginx.yml b/nginx/tasks/setup-nginx.yml index 4bda1ed..475ed07 100644 --- a/nginx/tasks/setup-nginx.yml +++ b/nginx/tasks/setup-nginx.yml @@ -1,14 +1,24 @@ --- - - name: install nginx - action: apt name=nginx - - - name: write nginx.conf - action: template src=templates/nginx.conf.j2 dest=/etc/nginx/nginx.conf - notify: - - restart nginx - - - name: delete default vhost - action: file path=/etc/nginx/sites-enabled/default state=absent - only_if: "$delete_default_vhost" - notify: - - restart nginx + +- name: Add nginx repo key + apt_key: + url: "http://nginx.org/keys/nginx_signing.key" + +- name: Add official APT repository + when: ansible_os_family == 'Debian' + apt_repository: + repo: "deb http://nginx.org/packages/{{ansible_distribution|lower}}/ {{ansible_distribution_release}} nginx" + +- name: install latest nginx version + action: apt name=nginx state=latest + +- name: write nginx.conf + action: template src=templates/nginx.conf.j2 dest=/etc/nginx/nginx.conf + notify: + - restart nginx + +- name: delete default vhost + action: file path=/etc/nginx/sites-enabled/default state=absent + only_if: "$delete_default_vhost" + notify: + - restart nginx