From 0fef56b4fae98b2d94bbdb1ac8d1abbf0a9986d6 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 18 Jul 2018 14:59:14 -0700 Subject: [PATCH] Install NGINX Unit on FreeBSD --- handlers/main.yml | 11 +++++++---- tasks/unit/install-modules.yml | 13 +++++++++++-- tasks/unit/install-unit.yml | 15 +++++++++++++-- tasks/unit/setup-freebsd.yml | 10 ++++++++++ 4 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 tasks/unit/setup-freebsd.yml diff --git a/handlers/main.yml b/handlers/main.yml index c674128..d9e22a6 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,17 +1,20 @@ --- -# Start NGINX - name: "(Handler: All OSs) Start NGINX" service: name: nginx state: started -# Reload NGINX - name: "(Handler: All OSs) Reload NGINX" service: name: nginx state: reloaded -- name: "(Handler: All OSs) Start NGINX Unit" +- name: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit" service: - name: unit + name: unitd + state: started + +- name: "(Handler: FreeBSD) Start NGINX Unit" + service: + name: unitd state: started diff --git a/tasks/unit/install-modules.yml b/tasks/unit/install-modules.yml index 36ba1fb..09d5cec 100644 --- a/tasks/unit/install-modules.yml +++ b/tasks/unit/install-modules.yml @@ -1,7 +1,16 @@ --- -- name: "(Install: All OSs) Install NGINX Unit Modules" +- name: "(Install: Debian/Ubuntu/CentOS/RedHat) Install NGINX Unit Modules" package: name: "{{ item }}" state: present with_items: "{{ unit_modules }}" - notify: "(Handler: All OSs) Start NGINX Unit" + when: ansible_os_family != "FreeBSD" + notify: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit" + +- name: "(Install: FreeBSD) Install NGINX Unit Modules" + portinstall: + name: "{{ item }}" + state: present + with_items: "{{ unit_modules }}" + when: ansible_os_family == "FreeBSD" + notify: "(Handler: FreeBSD) Start NGINX Unit" diff --git a/tasks/unit/install-unit.yml b/tasks/unit/install-unit.yml index 08dd30c..a616832 100644 --- a/tasks/unit/install-unit.yml +++ b/tasks/unit/install-unit.yml @@ -5,11 +5,22 @@ - import_tasks: setup-redhat.yml when: ansible_os_family == "RedHat" -- name: "(Install: All OSs) Install NGINX Unit" +- import_tasks: setup-freebsd.yml + when: ansible_os_family == "FreeBSD" + +- name: "(Install: Debian/Ubuntu/CentOS/RedHat) Install NGINX Unit" package: name: unit state: present - notify: "(Handler: All OSs) Start NGINX Unit" + when: ansible_os_family != "FreeBSD" + notify: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit" + +- name: "(Install: FreeBSD) Install NGINX Unit" + portinstall: + name: unit + state: present + when: ansible_os_family == "FreeBSD" + notify: "(Handler: FreeBSD) Start NGINX Unit" - import_tasks: install-modules.yml when: unit_modules is defined and unit_modules diff --git a/tasks/unit/setup-freebsd.yml b/tasks/unit/setup-freebsd.yml new file mode 100644 index 0000000..fdc1ae5 --- /dev/null +++ b/tasks/unit/setup-freebsd.yml @@ -0,0 +1,10 @@ +--- +- name: "(Install: FreeBSD) Fetch Ports" + command: portsnap fetch --interactive + args: + creates: /var/db/portsnap/INDEX + +- name: "(Install: FreeBSD) Extract Ports" + command: portsnap extract + args: + creates: /usr/ports