From 3d71531209b7a9ed6f55194d59cb12374bc1d420 Mon Sep 17 00:00:00 2001 From: Bartek Rutkowski Date: Fri, 22 Apr 2016 20:29:39 +0100 Subject: [PATCH] Add FreeBSD support. --- meta/main.yml | 9 ++++++++- tasks/main.yml | 7 +++++-- tasks/setup-FreeBSD.yml | 13 +++++++++++++ templates/nginx.conf.j2 | 2 +- vars/Debian.yml | 3 +++ vars/FreeBSD.yml | 9 +++++++++ vars/RedHat.yml | 3 +++ 7 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 tasks/setup-FreeBSD.yml create mode 100644 vars/FreeBSD.yml diff --git a/meta/main.yml b/meta/main.yml index c39d00b..fab65e4 100644 --- a/meta/main.yml +++ b/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 diff --git a/tasks/main.yml b/tasks/main.yml index f2cbd25..2363838 100644 --- a/tasks/main.yml +++ b/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 diff --git a/tasks/setup-FreeBSD.yml b/tasks/setup-FreeBSD.yml new file mode 100644 index 0000000..dedd05b --- /dev/null +++ b/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 \ No newline at end of file diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index d2b0fd4..8213eec 100644 --- a/templates/nginx.conf.j2 +++ b/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; diff --git a/vars/Debian.yml b/vars/Debian.yml index 7e4d549..cb12770 100644 --- a/vars/Debian.yml +++ b/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 diff --git a/vars/FreeBSD.yml b/vars/FreeBSD.yml new file mode 100644 index 0000000..bd2425d --- /dev/null +++ b/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" \ No newline at end of file diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 91164ce..0138f8d 100644 --- a/vars/RedHat.yml +++ b/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