roles/nginx: Use template for nginx repo

A template is better than ansible's `apt_repository` module because
we can idempotently control the contents of the file based on vari-
ables.

Signed-off-by: Alan Orth <alan.orth@gmail.com>
This commit is contained in:
Alan Orth 2015-05-25 00:15:49 +03:00
parent aa5a9f5dd8
commit 3746e798b6
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
3 changed files with 11 additions and 6 deletions

View File

@ -13,4 +13,8 @@ nginx_tls_protocols: TLSv1 TLSv1.1 TLSv1.2
# TLS key directory
tls_key_dir: /etc/ssl/private
# stable is 1.8.x
# mainline is 1.9.x
nginx_version: mainline
# vim: set ts=2 sw=2:

View File

@ -3,12 +3,8 @@
apt_key: url=http://nginx.org/keys/nginx_signing.key state=present
tags: nginx
- name: Add nginx.org mainline repo
apt_repository: repo="deb http://nginx.org/packages/mainline/ubuntu/ {{ ansible_distribution_release }} nginx" state=absent
tags: nginx
- name: Add nginx.org stable repo
apt_repository: repo="deb http://nginx.org/packages/ubuntu/ {{ ansible_distribution_release }} nginx" state=present
- name: Add nginx.org repo
template: src=nginx_org_packages_ubuntu.list.j2 dest=/etc/apt/sources.list.d/nginx_org_packages_ubuntu.list owner=root group=root mode=0644
tags: nginx
- name: Install nginx

View File

@ -0,0 +1,5 @@
{% if nginx_version == "stable" %}
deb http://nginx.org/packages/ubuntu/ {{ ansible_distribution_release }} nginx
{% elif nginx_version == "mainline" %}
deb http://nginx.org/packages/mainline/ubuntu/ {{ ansible_distribution_release }} nginx
{% endif %}