فهرست منبع

Issue #6 and PR #8: Make nginx user more flexible.

Jeff Geerling 10 سال پیش
والد
کامیت
fdc9a7da78
7فایلهای تغییر یافته به همراه16 افزوده شده و 6 حذف شده
  1. 2 2
      README.md
  2. 0 1
      defaults/main.yml
  3. 10 0
      tasks/main.yml
  4. 0 2
      tests/test.yml
  5. 2 0
      vars/Debian.yml
  6. 2 0
      vars/RedHat.yml
  7. 0 1
      vars/main.yml

+ 2 - 2
README.md

@@ -12,7 +12,7 @@ None.
 
 
 ## Role Variables
 ## Role Variables
 
 
-Available variables are listed below, along with default values (see `vars/main.yml` and `defaults/main.yml`):
+Available variables are listed below, along with default values (see `defaults/main.yml`):
 
 
     nginx_remove_default_vhost: false
     nginx_remove_default_vhost: false
     nginx_default_vhost_path: /etc/nginx/sites-enabled/default
     nginx_default_vhost_path: /etc/nginx/sites-enabled/default
@@ -21,7 +21,7 @@ Whether to remove the 'default' virtualhost configuration supplied by Nginx. Use
 
 
     nginx_user: "nginx"
     nginx_user: "nginx"
 
 
-The user under which Nginx will run.
+The user under which Nginx will run. Defaults to `nginx` for RedHat, and `www-data` for Debian.
 
 
     nginx_worker_processes: "1"
     nginx_worker_processes: "1"
     nginx_worker_connections: "8192"
     nginx_worker_connections: "8192"

+ 0 - 1
defaults/main.yml

@@ -1,5 +1,4 @@
 ---
 ---
-nginx_user: "nginx"
 nginx_worker_processes: "1"
 nginx_worker_processes: "1"
 nginx_worker_connections: "8192"
 nginx_worker_connections: "8192"
 nginx_client_max_body_size: "64m"
 nginx_client_max_body_size: "64m"

+ 10 - 0
tasks/main.yml

@@ -1,4 +1,14 @@
 ---
 ---
+# Variable setup.
+- name: Include OS-specific variables.
+  include_vars: "{{ ansible_os_family }}.yml"
+
+- name: Define nginx_user.
+  set_fact:
+    nginx_user: "{{ __nginx_user }}"
+  when: nginx_user is not defined
+
+# Nginx setup.
 - name: Enable nginx repo (RedHat).
 - name: Enable nginx repo (RedHat).
   copy: >
   copy: >
     src=nginx.repo
     src=nginx.repo

+ 0 - 2
tests/test.yml

@@ -1,7 +1,5 @@
 ---
 ---
 - hosts: localhost
 - hosts: localhost
   remote_user: root
   remote_user: root
-  vars:
-    nginx_user: root
   roles:
   roles:
     - ansible-role-nginx
     - ansible-role-nginx

+ 2 - 0
vars/Debian.yml

@@ -0,0 +1,2 @@
+---
+__nginx_user: "www-data"

+ 2 - 0
vars/RedHat.yml

@@ -0,0 +1,2 @@
+---
+__nginx_user: "nginx"

+ 0 - 1
vars/main.yml

@@ -1 +0,0 @@
----