From 856a9c93bf395e6c71110dd42c8c55cec44c5789 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 9 Sep 2020 16:10:42 +0200 Subject: [PATCH] Add NGINX Plus tests (#318) --- .travis.yml | 1 + README.md | 30 ++++++------- molecule/common/playbooks/plus_converge.yml | 31 +++++++++++++ molecule/common/playbooks/plus_verify.yml | 17 ++++++++ molecule/plus/molecule.yml | 48 +++++++++++++++++++++ molecule/plus_alpine/molecule.yml | 41 ++++++++++++++++++ molecule/plus_centos/molecule.yml | 30 +++++++++++++ 7 files changed, 183 insertions(+), 15 deletions(-) create mode 100644 molecule/common/playbooks/plus_converge.yml create mode 100644 molecule/common/playbooks/plus_verify.yml create mode 100644 molecule/plus/molecule.yml create mode 100644 molecule/plus_alpine/molecule.yml create mode 100644 molecule/plus_centos/molecule.yml diff --git a/.travis.yml b/.travis.yml index 2c9fbd2..34f55ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,6 +65,7 @@ before_install: install: - pip install ansible==2.9.13 - pip install ansible-lint==4.3.4 + - pip install yamllint==1.24.2 - pip install molecule==3.0.8 - pip install docker==4.3.1 script: diff --git a/README.md b/README.md index c34190a..70da1a4 100644 --- a/README.md +++ b/README.md @@ -162,29 +162,29 @@ Role Variables This role has multiple variables. The descriptions and defaults for all these variables can be found in the **`defaults/main`** directory in the following files: -- **[defaults/main/main.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/main.yml):** NGINX installation variables -- **[defaults/main/amplify.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/amplify.yml):** NGINX Amplify agent installation variables -- **[defaults/main/template.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/template.yml):** NGINX configuration templating variables -- **[defaults/main/upload.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/upload.yml):** NGINX configuration/HTML/SSL upload variables -- **[defaults/main/linux.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/linux.yml):** Linux installation variables -- **[defaults/main/bsd.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/bsd.yml):** BSD installation variables -- **[defaults/main/unit.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/unit.yml):** NGINX Unit installation variables +- **[defaults/main/main.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/main.yml):** NGINX installation variables +- **[defaults/main/amplify.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/amplify.yml):** NGINX Amplify agent installation variables +- **[defaults/main/template.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/template.yml):** NGINX configuration templating variables +- **[defaults/main/upload.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/upload.yml):** NGINX configuration/HTML/SSL upload variables +- **[defaults/main/linux.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/linux.yml):** Linux installation variables +- **[defaults/main/bsd.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/bsd.yml):** BSD installation variables +- **[defaults/main/unit.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/unit.yml):** NGINX Unit installation variables Similarly, descriptions and defaults for preset variables can be found in the **`vars`** directory: -- **[vars/main.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/vars/main.yml):** NGINX supported modules +- **[vars/main.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/vars/main.yml):** NGINX supported modules Example Playbooks ----------------- Working functional playbook examples can be found in the **`molecule/common`** directory in the following files: -- **[molecule/common/playbooks/default_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/default_converge.yml):** Install a specific version of NGINX and set up logrotate -- **[molecule/common/playbooks/module_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/module_converge.yml):** Install various NGINX supported modules -- **[molecule/common/playbooks/source_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/source_converge.yml):** Install NGINX from source -- **[molecule/common/playbooks/stable_push_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/stable_push_converge.yml):** Install NGINX using the stable branch and push a preexisting config from your system to your NGINX instance -- **[molecule/common/playbooks/template_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/template_converge.yml):** Use the NGINX configuration templating variables to create an NGINX configuration file -- **[molecule/common/playbooks/unit_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/unit_converge.yml):** Install NGINX Unit +- **[molecule/common/playbooks/default_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/default_converge.yml):** Install a specific version of NGINX and set up logrotate +- **[molecule/common/playbooks/module_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/module_converge.yml):** Install various NGINX supported modules +- **[molecule/common/playbooks/source_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/source_converge.yml):** Install NGINX from source +- **[molecule/common/playbooks/stable_push_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/stable_push_converge.yml):** Install NGINX using the stable branch and push a preexisting config from your system to your NGINX instance +- **[molecule/common/playbooks/template_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/template_converge.yml):** Use the NGINX configuration templating variables to create an NGINX configuration file +- **[molecule/common/playbooks/unit_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/unit_converge.yml):** Install NGINX Unit Do note that if you install this repository via Ansible Galaxy, you will have to replace the role variable in the sample playbooks from `ansible-role-nginx` to `nginxinc.nginx`. @@ -202,7 +202,7 @@ You can find an Ansible role to install NGINX Unit [here](https://github.com/ngi License ------- -[Apache License, Version 2.0](https://github.com/nginxinc/ansible-role-nginx/blob/master/LICENSE) +[Apache License, Version 2.0](https://github.com/nginxinc/ansible-role-nginx/blob/main/LICENSE) Author Information ------------------ diff --git a/molecule/common/playbooks/plus_converge.yml b/molecule/common/playbooks/plus_converge.yml new file mode 100644 index 0000000..27e4d43 --- /dev/null +++ b/molecule/common/playbooks/plus_converge.yml @@ -0,0 +1,31 @@ +--- +- name: Converge + hosts: all + tasks: + - name: Install NGINX + include_role: + name: ansible-role-nginx + vars: + nginx_type: plus + nginx_license: + certificate: ../../ansible-role-nginx/files/license/nginx-repo.crt + key: ../../ansible-role-nginx/files/license/nginx-repo.key + nginx_modules: + - auth-spnego + - brotli + - cookie-flag + - encrypted-session + - geoip + - geoip2 + - headers-more + - image-filter + - lua + - modsecurity + - njs + - opentracing + - passenger + - perl + - prometheus + - rtmp + - subs-filter + - xslt diff --git a/molecule/common/playbooks/plus_verify.yml b/molecule/common/playbooks/plus_verify.yml new file mode 100644 index 0000000..d69320c --- /dev/null +++ b/molecule/common/playbooks/plus_verify.yml @@ -0,0 +1,17 @@ +--- +- name: Verify + hosts: all + tasks: + - name: Check if NGINX service is running + service: + name: nginx + state: started + enabled: yes + check_mode: yes + register: service + failed_when: (service is changed) or (service is failed) + + - name: Verify NGINX is up and running + uri: + url: http://localhost + status_code: 200 diff --git a/molecule/plus/molecule.yml b/molecule/plus/molecule.yml new file mode 100644 index 0000000..53455ff --- /dev/null +++ b/molecule/plus/molecule.yml @@ -0,0 +1,48 @@ +--- +driver: + name: docker +lint: | + set -e + yamllint . + ansible-lint --force-color +platforms: + - name: debian-stretch + image: debian:stretch-slim + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" + - name: debian-buster + image: debian:buster-slim + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" + - name: ubuntu-xenial + image: ubuntu:xenial + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" + - name: ubuntu-bionic + image: ubuntu:bionic + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" + - name: ubuntu-focal + image: ubuntu:focal + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" +provisioner: + name: ansible + playbooks: + converge: ../common/playbooks/plus_converge.yml + verify: ../common/playbooks/plus_verify.yml diff --git a/molecule/plus_alpine/molecule.yml b/molecule/plus_alpine/molecule.yml new file mode 100644 index 0000000..08b8e83 --- /dev/null +++ b/molecule/plus_alpine/molecule.yml @@ -0,0 +1,41 @@ +--- +driver: + name: docker +lint: | + set -e + yamllint . + ansible-lint --force-color +platforms: + - name: alpine-3.8 + image: alpine:3.8 + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" + - name: alpine-3.9 + image: alpine:3.9 + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" + - name: alpine-3.10 + image: python:alpine3.10 + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" + - name: alpine-3.11 + image: python:alpine3.11 + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/sbin/init" +provisioner: + name: ansible + playbooks: + converge: ../common/playbooks/plus_converge.yml + verify: ../common/playbooks/plus_verify.yml diff --git a/molecule/plus_centos/molecule.yml b/molecule/plus_centos/molecule.yml new file mode 100644 index 0000000..f61e5f6 --- /dev/null +++ b/molecule/plus_centos/molecule.yml @@ -0,0 +1,30 @@ +--- +driver: + name: docker +lint: | + set -e + yamllint . + ansible-lint --force-color +platforms: + - name: centos-6 + image: centos:6 + dockerfile: ../common/Dockerfile.j2 + - name: centos-7 + image: centos:7 + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/usr/sbin/init" + - name: centos-8 + image: centos:8 + dockerfile: ../common/Dockerfile.j2 + privileged: true + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + command: "/usr/sbin/init" +provisioner: + name: ansible + playbooks: + converge: ../common/playbooks/plus_converge.yml + verify: ../common/playbooks/plus_verify.yml