Parcourir la source

PR #45: Clean up var names and document new feature.

Jeff Geerling il y a 9 ans
Parent
commit
e818255465
3 fichiers modifiés avec 21 ajouts et 12 suppressions
  1. 5 0
      README.md
  2. 4 3
      defaults/main.yml
  3. 12 9
      tasks/setup-Ubuntu.yml

+ 5 - 0
README.md

@@ -94,6 +94,11 @@ Extra lines to be inserted in the top-level `http` block in `nginx.conf`. The va
 
 (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
+
+(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`.
+
 ## Dependencies
 
 None.

+ 4 - 3
defaults/main.yml

@@ -2,6 +2,10 @@
 # Used only for Debian/Ubuntu installation, as the -t option for apt.
 nginx_default_release: ""
 
+# Use the official Nginx PPA for Ubuntu, and the version to use if so.
+nginx_ppa_use: false
+nginx_ppa_version: stable
+
 # The name of the nginx apt/yum package to install.
 nginx_package_name: "nginx"
 
@@ -60,6 +64,3 @@ nginx_upstreams: []
 #     "srv2.example.com weight=3",
 #     "srv3.example.com"
 #   }
-
-nginx_ppa_version: stable
-nginx_use_ppa: false

+ 12 - 9
tasks/setup-Ubuntu.yml

@@ -1,11 +1,14 @@
 ---
-  - 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: Add PPA for Nginx.
+  apt_repository:
+    repo: 'ppa:nginx/{{ nginx_ppa_version }}'
+    state: present
+    update_cache: yes
+  register: nginx_ppa_added
+  when: nginx_ppa_use
 
-  - name: ensure nginx is not installed when the ppa was just added
-    apt:
-      pkg: nginx
-      state: absent
-    when: added_ppa.changed
+- name: Ensure nginx will reinstall if the PPA was just added.
+  apt:
+    name: nginx
+    state: absent
+  when: nginx_ppa_added.changed