diff --git a/README.md b/README.md index 1c00cab..13b19db 100644 --- a/README.md +++ b/README.md @@ -141,10 +141,10 @@ Configures Nginx's [`log_format`](http://nginx.org/en/docs/http/ngx_http_log_mod (For Debian/Ubuntu only) Allows you to set a different repository for the installation of Nginx. As an example, if you are running Debian's wheezy release, and want to get a newer version of Nginx, you can install the `wheezy-backports` repository and set that value here, and Ansible will use that as the `-t` option while installing Nginx. - nginx_ppa_use: false - nginx_ppa_version: stable + nginx_repo_use: false + nginx_repo_mainline: false -(For Ubuntu only) Allows you to use the official Nginx PPA instead of the system's package. You can set the version to `stable` or `development`. +(For Ubuntu only) Allows you to use the official Nginx repository instead of the system's package. You can set the version to `stable` (default) or `mainline`. nginx_yum_repo_enabled: true diff --git a/defaults/main.yml b/defaults/main.yml index 0509dbe..13ff144 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,9 +5,9 @@ nginx_default_release: "" # Used only for Redhat installation, enables source Nginx repo. nginx_yum_repo_enabled: true -# Use the official Nginx PPA for Ubuntu, and the version to use if so. -nginx_ppa_use: false -nginx_ppa_version: stable +# Use the official Nginx repositories for Ubuntu, and the version to use (stable as default, alt: mainline) +nginx_repo_use: false +nginx_repo_mainline: false # The name of the nginx package to install. nginx_package_name: "nginx" diff --git a/tasks/setup-Ubuntu.yml b/tasks/setup-Ubuntu.yml index c608d25..21b8bb8 100644 --- a/tasks/setup-Ubuntu.yml +++ b/tasks/setup-Ubuntu.yml @@ -4,17 +4,28 @@ name: dirmngr state: present -- name: Add PPA for Nginx (if configured). +- name: Remove legacy ppa if present apt_repository: - repo: 'ppa:nginx/{{ nginx_ppa_version }}' - state: present - update_cache: true - register: nginx_ppa_added - when: nginx_ppa_use | bool + repo: ppa:nginx/stable + state: absent + +- name: Add nginx public key + apt_key: url=https://nginx.org/keys/nginx_signing.key + state=present + register: nginx_repo_added + when: nginx_repo_use | bool + +- name: Add nginx stable repository + apt_repository: repo='deb http://nginx.org/packages/{{ 'mainline/' if nginx_repo_mainline else ''}}ubuntu {{ ansible_distribution_release }} nginx' + state=present + mode=0644 + update_cache=true + register: nginx_repo_added + when: nginx_repo_use | bool -- name: Ensure nginx will reinstall if the PPA was just added. +- name: Ensure nginx will reinstall if the repo was just added. apt: name: nginx state: absent - when: nginx_ppa_added is changed + when: nginx_repo_added is changed tags: ['skip_ansible_lint']