Bladeren bron

Cleanup - This nginx role now works across RedHat and Debian.

Jeff Geerling 11 jaren geleden
bovenliggende
commit
45713939ee
3 gewijzigde bestanden met toevoegingen van 16 en 13 verwijderingen
  1. 2 6
      README.md
  2. 6 0
      meta/main.yml
  3. 8 7
      tasks/main.yml

+ 2 - 6
README.md

@@ -1,8 +1,8 @@
 # Ansible Role: Nginx
 
-Installs Nginx on RedHat/CentOS linux servers.
+Installs Nginx on RedHat/CentOS or Debian/Ubuntu linux servers.
 
-This role installs and configures the latest version of Nginx direct from the Nginx yum repository. You will likely need to do extra setup work after this role has installed Nginx, like adding your own [virtualhost].conf file inside `/etc/nginx/conf.d/`, describing the location and options to use for your particular website.
+This role installs and configures the latest version of Nginx from the Nginx yum repository (on RedHat-based systems) or via apt (on Debian-based systems). You will likely need to do extra setup work after this role has installed Nginx, like adding your own [virtualhost].conf file inside `/etc/nginx/conf.d/`, describing the location and options to use for your particular website.
 
 ## Requirements
 
@@ -39,10 +39,6 @@ None.
       roles:
         - { role: geerlingguy.nginx }
 
-## TODO
-
-  - Make this role work with all flavors of linux (as supported by nginx repos).
-
 ## License
 
 MIT / BSD

+ 6 - 0
meta/main.yml

@@ -11,6 +11,12 @@ galaxy_info:
   - name: EL
     versions:
     - 6
+  - name: Debian
+    versions:
+    - all
+  - name: Ubuntu
+    versions:
+    - all
   categories:
     - development
     - web

+ 8 - 7
tasks/main.yml

@@ -1,16 +1,17 @@
 ---
-- name: Enable nginx repo.
-  copy: src=nginx.repo dest=/etc/yum.repos.d/nginx.repo owner=root group=root mode=644
+- name: Enable nginx repo (RedHat).
+  copy: >
+    src=nginx.repo
+    dest=/etc/yum.repos.d/nginx.repo
+    owner=root group=root mode=644
   when: ansible_os_family == 'RedHat'
 
-- name: Ensure nginx is installed.
+- name: Ensure nginx is installed (RedHat).
   yum: pkg=nginx state=installed enablerepo=nginx
   when: ansible_os_family == 'RedHat'
 
-- name: Ensure nginx is installed.
-  apt: pkg=nginx state=installed update_cache=true
-  notify:
-    - restart nginx
+- name: Ensure nginx is installed (Debian).
+  apt: pkg=nginx state=installed
   when: ansible_os_family == 'Debian'
 
 - name: Copy nginx configuration in place.