Merge branch 'master' into (feature)/unit

Bring the (feature)/unit branch up to date with the master branch
This commit is contained in:
Alessandro Fael Garcia 2018-06-25 14:35:09 -07:00
commit 02db93d432
33 changed files with 472 additions and 148 deletions

View File

@ -1,30 +1,94 @@
--- ---
language: python sudo: required
python: "2.7" services:
# Use the new container infrastructure - docker
sudo: false env:
# Install ansible - distribution: centos
addons: version: 6
apt: playbook: basic
packages: - distribution: centos
- python-pip version: 6
install: playbook: push
# Install ansible - distribution: centos
- pip install ansible version: 6
# Check ansible version playbook: stable
- ansible --version - distribution: centos
# Create ansible.cfg with correct roles_path version: 6
- printf '[defaults]\nroles_path=../' >ansible.cfg playbook: template
- distribution: centos
version: 7
playbook: basic
- distribution: centos
version: 7
playbook: template
- distribution: centos
version: 7
playbook: stable
- distribution: centos
version: 7
playbook: push
- distribution: debian
version: jessie
playbook: basic
- distribution: debian
version: jessie
playbook: template
- distribution: debian
version: jessie
playbook: stable
- distribution: debian
version: jessie
playbook: push
- distribution: debian
version: stretch
playbook: basic
- distribution: debian
version: stretch
playbook: template
- distribution: debian
version: stretch
playbook: stable
- distribution: debian
version: stretch
playbook: push
- distribution: ubuntu
version: trusty
playbook: basic
- distribution: ubuntu
version: trusty
playbook: template
- distribution: ubuntu
version: trusty
playbook: stable
- distribution: ubuntu
version: trusty
playbook: push
- distribution: ubuntu
version: xenial
playbook: basic
- distribution: ubuntu
version: xenial
playbook: template
- distribution: ubuntu
version: xenial
playbook: stable
- distribution: ubuntu
version: xenial
playbook: push
before_install:
- 'sudo docker pull ${distribution}:${version}'
- 'sudo docker build --no-cache --rm --file=tests/dockerfiles/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
script: script:
# Basic role syntax check - container_id=$(mktemp)
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check - 'sudo docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume="${PWD}":/etc/ansible/roles/ansible-role-nginx:ro ${distribution}-${version}:ansible > "${container_id}"'
# Run the role with ansible-playbook. - 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/ansible-role-nginx/tests/playbooks/nginx-${playbook}.yml --syntax-check'
- ansible-playbook tests/test.yml -i tests/inventory --connection=local --sudo - 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/ansible-role-nginx/tests/playbooks/nginx-${playbook}.yml'
# Run the role again, checking to make sure it's idempotent.
- > - >
ansible-playbook tests/test.yml -i tests/inventory --connection=local --sudo | grep -q 'changed=0.*failed=0' sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/ansible-role-nginx/tests/playbooks/nginx-${playbook}.yml
&& (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) | grep -q 'changed=0.*failed=0'
# Request a page via the web server, to make sure NGINX is running and responds. && (echo 'Idempotence test: pass' && exit 0)
- curl http://localhost/ || (echo 'Idempotence test: fail' && exit 1)
- 'sudo docker exec "$(cat ${container_id})" curl http://localhost/'
- 'sudo docker rm -f "$(cat ${container_id})"'
notifications: notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ webhooks: https://galaxy.ansible.com/api/v1/notifications/

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) [![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) [![Build Status](https://travis-ci.org/nginxinc/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/nginxinc/ansible-role-nginx)
This role installs open source NGINX, NGINX Plus, or NGINX Unit on your target host. This role installs NGINX Open Source, NGINX Plus, or NGINX Unit on your target host.
Requirements Requirements
------------ ------------
@ -13,9 +13,9 @@ This role was developed using Ansible 2.4.0.0. Backwards compatibility is not gu
Use `ansible-galaxy install nginxinc.nginx` to install the role on your system. Use `ansible-galaxy install nginxinc.nginx` to install the role on your system.
It supports all platforms supported by [open source NGINX](https://nginx.org/en/linux_packages.html#mainline) and [NGINX Plus](https://www.nginx.com/products/technical-specs/): It supports all platforms supported by [NGINX Open Source](https://nginx.org/en/linux_packages.html#mainline) and [NGINX Plus](https://www.nginx.com/products/technical-specs/):
**Open Source NGINX:** **NGINX Open Source:**
CentOS: CentOS:
versions: versions:
@ -106,8 +106,27 @@ This role has multiple variables. The defaults for all these variables are the f
# Default is 'opensource'. # Default is 'opensource'.
type: opensource type: opensource
# Specify which branch of Open Source NGINX you want to install. # Specify repository origin for NGINX Open Source.
# Options are 'nginx_repository' or 'os_repository'.
# Only works if 'type' is set to 'opensource'.
# Default is nginx_repository.
install_from: nginx_repository
# Specify source repository for NGINX Open Source.
# Only works if 'install_from' is set to 'nginx_repository'.
# Defaults are the official NGINX repositories.
nginx_repository:
debian:
- 'deb https://nginx.org/packages/{{ "mainline/" if branch == "mainline" }}{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx'
- 'deb-src https://nginx.org/packages/{{ "mainline/" if branch == "mainline" }}{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx'
redhat:
- https://nginx.org/packages/{{ "mainline/" if branch == "mainline" }}{{ (ansible_distribution == "RedHat") | ternary('rhel/', 'centos/') }}{{ ansible_distribution_major_version|int }}/$basearch/
suse:
- https://nginx.org/packages/{{ "mainline/" if branch == "mainline" }}sles/12
# Specify which branch of NGINX Open Source you want to install.
# Options are 'mainline' or 'stable'. # Options are 'mainline' or 'stable'.
# Only works if 'install_from' is set to 'nginx_repository'.
# Default is mainline. # Default is mainline.
branch: mainline branch: mainline
@ -116,8 +135,7 @@ This role has multiple variables. The defaults for all these variables are the f
unit_enable: false unit_enable: false
unit_packages: false unit_packages: false
# Install nginscript, perl, waf (NGINX Plus only), geoip, image-filter, rtmp and/or xslt modules. # Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules. # Default is false.
# Default is false.
modules: modules:
njs: false njs: false
perl: false perl: false
@ -134,18 +152,15 @@ This role has multiple variables. The defaults for all these variables are the f
amplify_key: null amplify_key: null
# Enable NGINX status data. # Enable NGINX status data.
# Will enable 'stub_status' in open source NGINX and 'status' in NGINX Plus. # Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
# Default is false. # Default is false.
status_enable: false status_enable: false
# Enable NGINX Plus REST API and write access. # Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
# Default is false. # Default is false.
rest_api_enable: false rest_api_enable: false
rest_api_write: false rest_api_write: false
rest_api_dashboard: false
# Enable NGINX Plus dashboard. REST API also needs to be enabled.
# Default is false.
dashboard: false
# Location of your NGINX Plus license in your local machine. # Location of your NGINX Plus license in your local machine.
# Default is the files folder within the NGINX Ansible role. # Default is the files folder within the NGINX Ansible role.
@ -170,8 +185,8 @@ This role has multiple variables. The defaults for all these variables are the f
main_template_worker_processes: auto main_template_worker_processes: auto
main_template_error_level: warn main_template_error_level: warn
main_template_worker_connections: 1024 main_template_worker_connections: 1024
main_template_keepalive_timeout: 65
http_template_enable: false http_template_enable: false
http_template_keepalive_timeout: 65
http_template_listen: 80 http_template_listen: 80
http_template_server_name: localhost http_template_server_name: localhost
stream_template_enable: false stream_template_enable: false

View File

@ -4,8 +4,27 @@
# Default is 'opensource'. # Default is 'opensource'.
type: opensource type: opensource
# Specify which branch of Open Source NGINX you want to install. # Specify repository origin for NGINX Open Source.
# Options are 'nginx_repository' or 'os_repository'.
# Only works if 'type' is set to 'opensource'.
# Default is nginx_repository.
install_from: nginx_repository
# Specify source repository for NGINX Open Source.
# Only works if 'install_from' is set to 'nginx_repository'.
# Defaults are the official NGINX repositories.
nginx_repository:
debian:
- deb https://nginx.org/packages/{{ (branch == 'mainline') | ternary('mainline/','') }}{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx
- deb-src https://nginx.org/packages/{{ (branch == 'mainline') | ternary('mainline/','') }}{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx
redhat:
- https://nginx.org/packages/{{ (branch == 'mainline') | ternary('mainline/','') }}{{ (ansible_distribution == "RedHat") | ternary('rhel/', 'centos/') }}{{ ansible_distribution_major_version|int }}/$basearch/
suse:
- https://nginx.org/packages/{{ (branch == 'mainline') | ternary('mainline/','') }}sles/12
# Specify which branch of NGINX Open Source you want to install.
# Options are 'mainline' or 'stable'. # Options are 'mainline' or 'stable'.
# Only works if 'install_from' is set to 'nginx_repository'.
# Default is mainline. # Default is mainline.
branch: mainline branch: mainline
@ -14,7 +33,7 @@ branch: mainline
unit_enable: false unit_enable: false
unit_packages: false unit_packages: false
# Install nginscript, perl, waf (NGINX Plus only), geoip, image-filter, rtmp and/or xslt modules. # Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
# Default is false. # Default is false.
modules: modules:
njs: false njs: false
@ -32,18 +51,15 @@ amplify_enable: false
amplify_key: null amplify_key: null
# Enable NGINX status data. # Enable NGINX status data.
# Will enable 'stub_status' in open source NGINX and 'status' in NGINX Plus. # Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
# Default is false. # Default is false.
status_enable: false status_enable: false
# Enable NGINX Plus REST API and write access. # Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
# Default is false. # Default is false.
rest_api_enable: false rest_api_enable: false
rest_api_write: false rest_api_write: false
rest_api_dashboard: false
# Enable NGINX Plus dashboard. REST API also needs to be enabled.
# Default is false.
dashboard: false
# Location of your NGINX Plus license in your local machine. # Location of your NGINX Plus license in your local machine.
# Default is the files folder within the NGINX Ansible role. # Default is the files folder within the NGINX Ansible role.
@ -68,8 +84,8 @@ main_template_user: nginx
main_template_worker_processes: auto main_template_worker_processes: auto
main_template_error_level: warn main_template_error_level: warn
main_template_worker_connections: 1024 main_template_worker_connections: 1024
main_template_keepalive_timeout: 65
http_template_enable: false http_template_enable: false
http_template_keepalive_timeout: 65
http_template_listen: 80 http_template_listen: 80
http_template_server_name: localhost http_template_server_name: localhost
stream_template_enable: false stream_template_enable: false

View File

@ -1,25 +1,40 @@
--- ---
- name: "(Setup: All NGINX) Upload NGINX Main Configuration File" - name: "(Setup: All NGINX) Upload NGINX Main Configuration File"
copy: copy:
src: "{{ main_upload_location }}" src: "{{ main_push_location }}"
dest: /etc/nginx/nginx.conf dest: /etc/nginx/nginx.conf
backup: yes
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"
when: main_upload_enable when: main_push_enable
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
file:
path: /etc/nginx/conf.d/http
state: directory
when: http_push_enable
- name: "(Setup: All NGINX) Upload NGINX HTTP Configuration Files" - name: "(Setup: All NGINX) Upload NGINX HTTP Configuration Files"
copy: copy:
src: "{{ item }}" src: "{{ item }}"
dest: /etc/nginx/conf.d/ dest: /etc/nginx/conf.d/http
backup: yes
with_fileglob: with_fileglob:
- "{{ http_upload_location }}" - "{{ http_push_location }}"
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"
when: http_upload_enable when: http_push_enable
- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists"
file:
path: /etc/nginx/conf.d/stream
state: directory
when: stream_push_enable
- name: "(Setup: All NGINX) Upload NGINX Stream Configuration Files" - name: "(Setup: All NGINX) Upload NGINX Stream Configuration Files"
copy: copy:
src: "{{ item }}" src: "{{ item }}"
dest: /etc/nginx/conf.d/ dest: /etc/nginx/conf.d/stream
backup: yes
with_fileglob: with_fileglob:
- "{{ stream_upload_location }}" - "{{ stream_push_location }}"
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"
when: stream_upload_enable when: stream_push_enable

View File

@ -1,6 +1,22 @@
--- ---
- name: "(Setup: NGINX Plus) Setup NGINX Plus API" - name: "(Setup: NGINX Plus) Setup NGINX Plus API"
template: blockinfile:
src: api.conf.j2 path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/api.conf','/etc/nginx/conf.d/api.conf') }}"
dest: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/api.conf','/etc/nginx/conf.d/api.conf') }}" create: yes
block: |
server {
listen 8080;
location /api {
{% if rest_api_write %}
api write=on;
{% else %}
api;
{% endif %}
}
{% if rest_api_dashboard %}
location = /dashboard.html {
root /usr/share/nginx/html;
}
{% endif %}
}
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"

View File

@ -1,7 +1,7 @@
--- ---
- name: "(Setup: Open Source NGINX) Enable Open Source NGINX Status" - name: "(Setup: NGINX Open Source) Enable NGINX Open Source Status"
blockinfile: blockinfile:
path: /etc/nginx/conf.d/stub_status.conf path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/stub_status.conf','/etc/nginx/conf.d/stub_status.conf') }}"
create: yes create: yes
block: | block: |
server { server {
@ -17,7 +17,7 @@
- name: "(Setup: NGINX Plus) Enable NGINX Plus Status" - name: "(Setup: NGINX Plus) Enable NGINX Plus Status"
blockinfile: blockinfile:
path: /etc/nginx/conf.d/status.conf path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/status.conf','/etc/nginx/conf.d/status.conf') }}"
create: yes create: yes
block: | block: |
server { server {

View File

@ -3,20 +3,38 @@
template: template:
src: nginx.conf.j2 src: nginx.conf.j2
dest: /etc/nginx/nginx.conf dest: /etc/nginx/nginx.conf
backup: yes
when: main_template_enable
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
file:
path: /etc/nginx/conf.d/http
state: directory
when: http_template_enable
- name: "(Setup: All NGINX) Dynamically Generate NGINX HTTP Configuration Files" - name: "(Setup: All NGINX) Dynamically Generate NGINX HTTP Configuration Files"
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: /etc/nginx/conf.d/{{ item | basename | regex_replace('\.j2','') }} dest: /etc/nginx/conf.d/http/{{ item | basename | regex_replace('\.j2','') }}
backup: yes
with_fileglob: with_fileglob:
- "../templates/http/*.j2" - "../templates/http/*.j2"
when: http_template_enable
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"
- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists"
file:
path: /etc/nginx/conf.d/stream
state: directory
when: stream_template_enable
- name: "(Setup: All NGINX) Dynamically Generate NGINX Stream Configuration Files" - name: "(Setup: All NGINX) Dynamically Generate NGINX Stream Configuration Files"
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: /etc/nginx/conf.d/{{ item | basename | regex_replace('\.j2','') }} dest: /etc/nginx/conf.d/stream/{{ item | basename | regex_replace('\.j2','') }}
backup: yes
with_fileglob: with_fileglob:
- "../templates/stream/*.j2" - "../templates/stream/*.j2"
when: stream_template_enable
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"

View File

@ -1,5 +1,5 @@
--- ---
- name: "(Install: All OSs) Install Open Source NGINX GeoIP Module" - name: "(Install: All OSs) Install NGINX Open Source GeoIP Module"
package: package:
name: nginx-geoip-perl name: nginx-geoip-perl
state: present state: present

View File

@ -1,5 +1,5 @@
--- ---
- name: "(Install: All OSs) Install Open Source NGINX Image Filter Module" - name: "(Install: All OSs) Install NGINX Open Source Image Filter Module"
package: package:
name: nginx-module-image-filter name: nginx-module-image-filter
state: present state: present

View File

@ -1,17 +1,17 @@
--- ---
- name: "(Install: All OSs) Install Open Source NGINX NJS Module" - name: "(Install: All OSs) Install NGINX Open Source JavaScript Module"
package: package:
name: nginx-module-njs name: nginx-module-njs
state: present state: present
when: type == "opensource" when: type == "opensource"
- name: "(Install: All OSs) Install NGINX Plus NJS Module" - name: "(Install: All OSs) Install NGINX Plus JavaScript Module"
package: package:
name: nginx-plus-module-njs name: nginx-plus-module-njs
state: present state: present
when: type == "plus" when: type == "plus"
- name: "(Setup: All NGINX) Load NGINX NJS Module" - name: "(Setup: All NGINX) Load NGINX JavaScript Module"
blockinfile: blockinfile:
path: /etc/nginx/nginx.conf path: /etc/nginx/nginx.conf
insertbefore: BOF insertbefore: BOF

View File

@ -1,5 +1,5 @@
--- ---
- name: "(Install: All OSs) Install Open Source NGINX Perl Module" - name: "(Install: All OSs) Install NGINX Open Source Perl Module"
package: package:
name: nginx-module-perl name: nginx-module-perl
state: present state: present

View File

@ -1,5 +1,5 @@
--- ---
- name: "(Install: All OSs) Install Open Source NGINX RTMP Module" - name: "(Install: All OSs) Install NGINX Open Source RTMP Module"
package: package:
name: nginx-module-rtmp name: nginx-module-rtmp
state: present state: present

View File

@ -1,5 +1,5 @@
--- ---
- name: "(Install: All OSs) Install Open Source NGINX XSLT Module" - name: "(Install: All OSs) Install NGINX Open Source XSLT Module"
package: package:
name: nginx-module-xslt name: nginx-module-xslt
state: present state: present

View File

@ -1,4 +1,7 @@
--- ---
- name: ""
block:
- import_tasks: setup-debian.yml - import_tasks: setup-debian.yml
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
@ -8,8 +11,28 @@
- import_tasks: setup-suse.yml - import_tasks: setup-suse.yml
when: ansible_os_family == "Suse" when: ansible_os_family == "Suse"
- name: "(Install: All OSs) Install NGINX" - import_tasks: setup-freebsd.yml
when: ansible_os_family == "FreeBSD"
- name: "(Install: Debian/Ubuntu/CentOS/RedHat) Install NGINX"
package: package:
name: nginx name: nginx
state: present state: present
when: ansible_os_family != "FreeBSD"
notify: "(Handler: All OSs) Start NGINX"
- name: "(Install: FreeBSD) Install NGINX"
portinstall:
name: nginx
state: present
when: ansible_os_family == "FreeBSD"
notify: "(Handler: All OSs) Start NGINX"
when: install_from == "nginx_repository"
- name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX"
package:
name: nginx
state: present
when: install_from == "os_repository"
notify: "(Handler: All OSs) Start NGINX" notify: "(Handler: All OSs) Start NGINX"

View File

@ -1,16 +1,6 @@
--- ---
- name: "(Install: Debian/Ubuntu) Add Mainline NGINX Repository" - name: "(Install: Debian/Ubuntu) Add NGINX Repository"
apt_repository: apt_repository:
repo: "{{ item }}" repo: "{{ item }}"
with_items: with_items:
- deb https://nginx.org/packages/mainline/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx - "{{ nginx_repository.debian }}"
- deb-src https://nginx.org/packages/mainline/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx
when: branch == "mainline"
- name: "(Install: Debian/Ubuntu) Add Stable NGINX Repository"
apt_repository:
repo: "{{ item }}"
with_items:
- deb https://nginx.org/packages/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx
- deb-src https://nginx.org/packages/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx
when: branch == "stable"

View File

@ -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

View File

@ -1,36 +1,8 @@
--- ---
- name: "(Install: RedHat) Add Mainline NGINX Repository" - name: "(Install: CentOS/RedHat) Add NGINX Repository"
yum_repository: yum_repository:
name: nginx name: nginx
baseurl: https://nginx.org/packages/mainline/rhel/{{ ansible_distribution_major_version|int }}/$basearch/ baseurl: "{{ nginx_repository.redhat }}"
description: NGINX Repository description: NGINX Repository
enabled: yes enabled: yes
gpgcheck: yes gpgcheck: yes
when: branch == "mainline" and ansible_distribution == "RedHat"
- name: "(Install: CentOS) Add Mainline NGINX Repository"
yum_repository:
name: nginx
baseurl: https://nginx.org/packages/mainline/centos/{{ ansible_distribution_major_version|int }}/$basearch/
description: NGINX Repository
enabled: yes
gpgcheck: yes
when: branch == "mainline" and ansible_distribution == "CentOS"
- name: "(Install: RedHat) Add Stable NGINX Repository"
yum_repository:
name: nginx
baseurl: https://nginx.org/packages/rhel/{{ ansible_distribution_major_version|int }}/$basearch/
description: NGINX Repository
enabled: yes
gpgcheck: yes
when: branch == "stable" and ansible_distribution == "RedHat"
- name: "(Install: CentOS) Add Stable NGINX Repository"
yum_repository:
name: nginx
baseurl: https://nginx.org/packages/centos/{{ ansible_distribution_major_version|int }}/$basearch/
description: NGINX Repository
enabled: yes
gpgcheck: yes
when: branch == "stable" and ansible_distribution == "CentOS"

View File

@ -1,12 +1,5 @@
--- ---
- name: "(Install: SUSE) Add Mainline NGINX Repository" - name: "(Install: SUSE) Add NGINX Repository"
zypper_repository: zypper_repository:
name: nginx name: nginx
repo: https://nginx.org/packages/mainline/sles/12 repo: "{{ nginx_repository.suse }}"
when: branch == "mainline"
- name: "(Install: SUSE) Add Stable NGINX Repository"
zypper_repository:
name: nginx
repo: https://nginx.org/packages/sles/12
when: branch == "stable"

View File

@ -1,17 +0,0 @@
{% if rest_api_enable %}
server {
listen 8080;
location /api {
{% if rest_api_write %}
api write=on;
{% else %}
api;
{% endif %}
}
{% if dashboard %}
location = /dashboard.html {
root /usr/share/nginx/html;
}
{% endif %}
}
{% endif %}

View File

@ -23,7 +23,7 @@ http {
sendfile on; sendfile on;
#tcp_nopush on; #tcp_nopush on;
keepalive_timeout {{ main_template_keepalive_timeout }}; keepalive_timeout {{ http_template_keepalive_timeout }};
#gzip on; #gzip on;

View File

@ -0,0 +1,12 @@
FROM centos:6
RUN yum -y install epel-release
RUN yum -y install git ansible sudo
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
VOLUME ["/sys/fs/cgroup"]
CMD ["/sbin/init"]

View File

@ -0,0 +1,24 @@
FROM centos:7
# Install systemd -- See https://hub.docker.com/_/centos/
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
RUN yum -y update; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN yum -y install epel-release
RUN yum -y install git ansible sudo
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
VOLUME ["/sys/fs/cgroup"]
CMD ["/usr/sbin/init"]

View File

@ -0,0 +1,19 @@
FROM debian:jessie
RUN apt-get update -y && apt-get install -y --no-install-recommends \
software-properties-common \
build-essential \
libffi-dev \
libssl-dev \
python-dev \
python-pip \
git \
apt-transport-https \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade setuptools && pip install ansible
RUN mkdir -p /etc/ansible && echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
ENTRYPOINT ["/sbin/init"]

View File

@ -0,0 +1,22 @@
FROM debian:stretch
RUN apt-get update -y && apt-get install -y --no-install-recommends \
software-properties-common \
build-essential \
libffi-dev \
libssl-dev \
python-dev \
python-pip \
git \
systemd \
apt-transport-https \
curl \
gnupg2 \
dirmngr \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade setuptools && pip install ansible
RUN mkdir -p /etc/ansible && echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
ENTRYPOINT ["/bin/systemd"]

View File

@ -0,0 +1,14 @@
FROM ubuntu:trusty
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 \
&& rm -rf /var/lib/apt/lists/*
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
ENTRYPOINT ["/sbin/init"]

View File

@ -0,0 +1,14 @@
FROM ubuntu:xenial
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 \
&& rm -rf /var/lib/apt/lists/*
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
ENTRYPOINT ["/sbin/init"]

View File

@ -0,0 +1,44 @@
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

31
tests/files/nginx.conf Normal file
View File

@ -0,0 +1,31 @@
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}

View File

@ -1 +0,0 @@
localhost

View File

@ -1,5 +1,6 @@
--- ---
- hosts: localhost - hosts: localhost
become: true
remote_user: root remote_user: root
roles: roles:
- ansible-role-nginx - ansible-role-nginx

View File

@ -0,0 +1,11 @@
---
- hosts: localhost
become: true
remote_user: root
roles:
- ansible-role-nginx
vars:
main_push_enable: true
main_push_location: ../files/nginx.conf
http_push_enable: true
http_push_location: ../files/http/*.conf

View File

@ -0,0 +1,8 @@
---
- hosts: localhost
become: true
remote_user: root
roles:
- ansible-role-nginx
vars:
branch: stable

View File

@ -0,0 +1,10 @@
---
- hosts: localhost
become: true
remote_user: root
roles:
- ansible-role-nginx
vars:
http_template_enable: true
http_template_keepalive_timeout: 70
http_template_listen: 82