Merge pull request #37 from nginxinc/(feature)/unit

(feature)/unit
This commit is contained in:
Alessandro Fael Garcia 2018-06-27 16:13:34 -07:00 committed by GitHub
commit fa9f2ae5af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 200 additions and 16 deletions

View File

@ -15,6 +15,9 @@ env:
- distribution: centos
version: 6
playbook: template
- distribution: centos
version: 6
playbook: unit
- distribution: centos
version: 7
playbook: basic
@ -27,6 +30,9 @@ env:
- distribution: centos
version: 7
playbook: push
- distribution: centos
version: 7
playbook: unit
- distribution: debian
version: jessie
playbook: basic
@ -39,6 +45,9 @@ env:
- distribution: debian
version: jessie
playbook: push
- distribution: debian
version: jessie
playbook: unit
- distribution: debian
version: stretch
playbook: basic
@ -51,6 +60,9 @@ env:
- distribution: debian
version: stretch
playbook: push
- distribution: debian
version: stretch
playbook: unit
- distribution: ubuntu
version: trusty
playbook: basic
@ -75,6 +87,39 @@ env:
- distribution: ubuntu
version: xenial
playbook: push
- distribution: ubuntu
version: xenial
playbook: unit
- distribution: ubuntu
version: artful
playbook: basic
- distribution: ubuntu
version: artful
playbook: push
- distribution: ubuntu
version: artful
playbook: stable
- distribution: ubuntu
version: artful
playbook: template
- distribution: ubuntu
version: artful
playbook: unit
- distribution: ubuntu
version: bionic
playbook: basic
- distribution: ubuntu
version: bionic
playbook: push
- distribution: ubuntu
version: bionic
playbook: stable
- distribution: ubuntu
version: bionic
playbook: template
- distribution: ubuntu
version: bionic
playbook: unit
before_install:
- 'sudo docker pull ${distribution}:${version}'
- 'sudo docker build --no-cache --rm --file=tests/dockerfiles/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'

View File

@ -4,7 +4,7 @@ Ansible NGINX Role
[![Ansible Galaxy](https://img.shields.io/badge/galaxy-nginxinc.nginx-5bbdbf.svg)](https://galaxy.ansible.com/nginxinc/nginx)
[![Build Status](https://travis-ci.org/nginxinc/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/nginxinc/ansible-role-nginx)
This role installs NGINX Open Source or NGINX Plus on your target host.
This role installs NGINX Open Source, NGINX Plus, or NGINX Unit on your target host.
Requirements
------------
@ -40,6 +40,41 @@ It supports all platforms supported by [NGINX Open Source](https://nginx.org/en/
**NGINX Plus:**
Debian:
versions:
- jessie
- stretch
Ubuntu:
versions:
- trusty
- xenial
- zesty
- artful
CentOS:
versions:
- 6.5
- 7
RedHat:
versions:
- 6.5
- 7
Oracle Linux:
versions:
- 6.5
- 7
Amazon Linux:
versions:
- 2016.09
SUSE/SLES:
versions:
- 12
FreeBSD:
versions:
- 10.3
- 11
**NGINX Unit:**
CentOS:
versions:
- 6
@ -50,25 +85,13 @@ It supports all platforms supported by [NGINX Open Source](https://nginx.org/en/
- 7
Debian:
versions:
- wheezy
- jessie
- stretch
Ubuntu:
versions:
- trusty
- xenial
- zesty
SUSE/SLES:
versions:
- 12
FreeBSD:
versions:
- 10.3
- 11
Oracle Linux:
versions:
- 6.5
- 7
- artful
- bionic
Amazon Linux:
versions:
- 2016.09
@ -108,8 +131,12 @@ This role has multiple variables. The defaults for all these variables are the f
# Default is mainline.
branch: mainline
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
# Install NGINX Unit and NGINX Unit packages.
# Default is false.
unit_enable: false
unit_packages: false
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules. # Default is false.
modules:
njs: false
perl: false
@ -200,6 +227,17 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role to a
roles:
- role: nginxinc.nginx
This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a localhost to install NGINX Unit and all NGINX Unit language packages.
---
- hosts: localhost
become: true
roles:
- role: nginxinc.nginx
vars:
- unit_enable: true
- unit_packages: true
To run any of the above sample playbooks create a `setup-nginx.yml` file and paste the contents. Executing the Ansible Playbook is then as simple as executing `ansible-playbook setup-nginx.yml`.
Alternatively, you can also clone this repository instead of installing it from Ansible Galaxy. If you decide to do so, replace the role variable in the previous sample playbooks from `nginxinc.nginx` to `ansible-role-nginx`.

View File

@ -28,6 +28,12 @@ nginx_repository:
# Default is mainline.
branch: mainline
# Install NGINX Unit and NGINX Unit modules.
# Use a list of supported NGINX Unit modules.
# Default is false.
unit_enable: false
unit_modules: null
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
# Default is false.
modules:

View File

@ -10,3 +10,8 @@
service:
name: nginx
state: reloaded
- name: "(Handler: All OSs) Start NGINX Unit"
service:
name: unit
state: started

View File

@ -46,3 +46,6 @@
- import_tasks: amplify/install-amplify.yml
when: amplify_enable and amplify_key is defined and amplify_key
- import_tasks: unit/install-unit.yml
when: unit_enable

View File

@ -0,0 +1,6 @@
- name: "(Install: All OSs) Install NGINX Unit Modules"
package:
name: "{{ item }}"
state: present
with_items: "{{ unit_modules }}"
notify: "(Handler: All OSs) Start NGINX Unit"

View File

@ -0,0 +1,15 @@
---
- import_tasks: setup-debian.yml
when: ansible_os_family == "Debian"
- import_tasks: setup-redhat.yml
when: ansible_os_family == "RedHat"
- name: "(Install: All OSs) Install NGINX Unit"
package:
name: unit
state: present
notify: "(Handler: All OSs) Start NGINX Unit"
- import_tasks: install-modules.yml
when: unit_modules is defined and unit_modules

View File

@ -0,0 +1,7 @@
---
- name: "(Install: Debian/Ubuntu) Add NGINX Unit Repository"
apt_repository:
repo: "{{ item }}"
with_items:
- deb https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit
- deb-src https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit

View File

@ -0,0 +1,18 @@
---
- name: "(Install: CentOS/RedHat) Add NGINX Unit Repository"
yum_repository:
name: unit
baseurl: https://packages.nginx.org/unit/{{ (ansible_distribution == "RedHat") | ternary('rhel/', 'centos/') }}$releasever/$basearch/
description: NGINX Unit Repository
enabled: yes
gpgcheck: yes
when: ansible_distribution != "Amazon"
- name: "(Install: Amazon Linux) Add NGINX Unit Repository"
yum_repository:
name: unit
baseurl: https://packages.nginx.org/unit/amzn/$releasever/$basearch/
description: NGINX Unit Repository
enabled: yes
gpgcheck: yes
when: ansible_distribution == "Amazon"

View File

@ -0,0 +1,15 @@
FROM ubuntu:artful
RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y software-properties-common && rm -rf /var/lib/apt/lists/*
RUN apt-add-repository -y ppa:ansible/ansible && apt-get update && apt-get install -y \
git \
ansible \
apt-transport-https \
curl \
init \
&& rm -rf /var/lib/apt/lists/*
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
ENTRYPOINT ["/sbin/init"]

View File

@ -0,0 +1,15 @@
FROM ubuntu:bionic
RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y software-properties-common && rm -rf /var/lib/apt/lists/*
RUN apt-add-repository -y ppa:ansible/ansible && apt-get update && apt-get install -y \
git \
ansible \
apt-transport-https \
curl \
init \
&& rm -rf /var/lib/apt/lists/*
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
ENTRYPOINT ["/sbin/init"]

View File

@ -0,0 +1,11 @@
---
- hosts: localhost
become: true
remote_user: root
roles:
- ansible-role-nginx
vars:
unit_enable: true
unit_modules:
- unit-php
- unit-perl