From 3063875875100edc879361d29ca32f883f4fa488 Mon Sep 17 00:00:00 2001 From: Frederik Wille Date: Mon, 8 Feb 2016 17:52:09 +0100 Subject: [PATCH] add official nginx ppa for ubuntu adds ppa:nginx to apt repositories when nginx_use_ppa is set to yes (default no) nginx_ppa_version can be either "stable" or "development" this will reinstall nginx if ppa was just added to ensure that the ppa version will be installed --- defaults/main.yml | 3 +++ tasks/main.yml | 3 +++ tasks/setup-Ubuntu.yml | 11 +++++++++++ tests/test.yml | 3 ++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tasks/setup-Ubuntu.yml diff --git a/defaults/main.yml b/defaults/main.yml index 74b900c..f5ca355 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -50,3 +50,6 @@ nginx_upstreams: [] # "srv2.example.com weight=3", # "srv3.example.com" # } + +nginx_ppa_version: stable +nginx_use_ppa: false diff --git a/tasks/main.yml b/tasks/main.yml index 116e75e..f2cbd25 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,6 +12,9 @@ - include: setup-RedHat.yml when: ansible_os_family == 'RedHat' +- include: setup-Ubuntu.yml + when: ansible_distribution == 'Ubuntu' + - include: setup-Debian.yml when: ansible_os_family == 'Debian' diff --git a/tasks/setup-Ubuntu.yml b/tasks/setup-Ubuntu.yml new file mode 100644 index 0000000..011d177 --- /dev/null +++ b/tasks/setup-Ubuntu.yml @@ -0,0 +1,11 @@ +--- + - name: Add PPA for Nginx. + apt_repository: repo='ppa:nginx/{{ nginx_ppa_version }}' state=present update_cache=yes + register: added_ppa + when: nginx_use_ppa + + - name: ensure nginx is not installed when the ppa was just added + apt: + pkg: nginx + state: absent + when: added_ppa.changed diff --git a/tests/test.yml b/tests/test.yml index 42bba2c..5b55b97 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -2,4 +2,5 @@ - hosts: localhost remote_user: root roles: - - ansible-role-nginx + - role: ansible-role-nginx + nginx_use_ppa: true