Bartek Rutkowski преди 9 години
родител
ревизия
3d71531209
променени са 7 файла, в които са добавени 42 реда и са изтрити 4 реда
  1. 8 1
      meta/main.yml
  2. 5 2
      tasks/main.yml
  3. 13 0
      tasks/setup-FreeBSD.yml
  4. 1 1
      templates/nginx.conf.j2
  5. 3 0
      vars/Debian.yml
  6. 9 0
      vars/FreeBSD.yml
  7. 3 0
      vars/RedHat.yml

+ 8 - 1
meta/main.yml

@@ -3,7 +3,7 @@ dependencies: []
 
 galaxy_info:
   author: geerlingguy
-  description: Nginx installation for Linux/UNIX.
+  description: Nginx installation for Linux and FreeBSD.
   company: "Midwestern Mac, LLC"
   license: "license (BSD, MIT)"
   min_ansible_version: 1.8
@@ -18,6 +18,13 @@ galaxy_info:
     - name: Ubuntu
       versions:
       - all
+    - name: FreeBSD
+      versions:
+      - 10.3
+      - 10.2
+      - 10.1
+      - 10.0
+      - 9.3
   galaxy_tags:
     - development
     - web

+ 5 - 2
tasks/main.yml

@@ -18,6 +18,9 @@
 - include: setup-Debian.yml
   when: ansible_os_family == 'Debian'
 
+- include: setup-FreeBSD.yml
+  when: ansible_os_family == 'FreeBSD'
+
 # Vhost configuration.
 - include: vhosts.yml
 
@@ -25,9 +28,9 @@
 - name: Copy nginx configuration in place.
   template:
     src: nginx.conf.j2
-    dest: /etc/nginx/nginx.conf
+    dest: "{{ nginx_conf_file_path }}"
     owner: root
-    group: root
+    group: "{{ root_group }}"
     mode: 0644
   notify:
     - reload nginx

+ 13 - 0
tasks/setup-FreeBSD.yml

@@ -0,0 +1,13 @@
+---
+- name: Update pkg cache.
+  shell: pkg update -f
+
+- name: Ensure nginx is installed.
+  pkgng:
+    name: "{{ nginx_package_name }}"
+    state: present
+
+- name: Create logs directory.
+  file:
+    path: /var/log/nginx
+    state: directory

+ 1 - 1
templates/nginx.conf.j2

@@ -15,7 +15,7 @@ events {
 {% endif %}
 
 http {
-    include       /etc/nginx/mime.types;
+    include       {{ nginx_mime_file_path }};
     default_type  application/octet-stream;
 
     server_names_hash_bucket_size 64;

+ 3 - 0
vars/Debian.yml

@@ -1,5 +1,8 @@
 ---
+root_group: root
 nginx_conf_path: /etc/nginx/conf.d
+nginx_conf_file_path: /etc/nginx/nginx.conf
+nginx_mime_file_path: /etc/nginx/mime.types
 nginx_pidfile: /run/nginx.pid
 nginx_vhost_path: /etc/nginx/sites-enabled
 nginx_default_vhost_path: /etc/nginx/sites-enabled/default

+ 9 - 0
vars/FreeBSD.yml

@@ -0,0 +1,9 @@
+---
+root_group: wheel
+nginx_conf_path: /usr/local/etc/nginx/conf.d
+nginx_conf_file_path: /usr/local/etc/nginx/nginx.conf
+nginx_mime_file_path: /usr/local/etc/nginx/mime.types
+nginx_pidfile: /var/run/nginx.pid
+nginx_vhost_path: /usr/local/etc/nginx/sites-enabled
+nginx_default_vhost_path: /usr/local/etc/nginx/sites-enabled/default
+__nginx_user: "www"

+ 3 - 0
vars/RedHat.yml

@@ -1,5 +1,8 @@
 ---
+root_group: root
 nginx_conf_path: /etc/nginx/conf.d
+nginx_conf_file_path: /etc/nginx/nginx.conf
+nginx_mime_file_path: /etc/nginx/mime.types
 nginx_pidfile: /var/run/nginx.pid
 nginx_vhost_path: /etc/nginx/conf.d
 nginx_default_vhost_path: /etc/nginx/conf.d/default.conf