Compare commits

...

56 Commits

Author SHA1 Message Date
Jeff Geerling dbd7d57194
Merge pull request #248 from jon4hz/master
feat: support suse
2024-03-23 23:03:16 -05:00
jon4hz 016415bdaf
feat: support suse 2024-03-23 23:30:35 +01:00
Jeff Geerling 01381ec321 A wee bit of modernization. 2024-01-24 22:02:49 -06:00
Jeff Geerling 3e4db55e8e Make local dev with molecule a little easier. 2024-01-24 21:55:44 -06:00
Jeff Geerling db216a2076 Stale bot is now Stale GitHub Action. 2023-07-10 17:48:17 -05:00
Jeff Geerling a2e99e7053 Remove official support for RHEL. Rocky/Alma/Stream support is best-effort. 2023-06-23 10:56:57 -05:00
Jeff Geerling 13b29b765d Fix Molecule CI workflow since docker plugin has moved. 2023-04-20 17:27:53 -05:00
Jeff Geerling bb6ee693ab
Merge pull request #236 from thomasp1992/handle-alma-linux
Handle alma linux
2022-12-07 04:07:23 +00:00
Jeff Geerling 029d62ee83 Fix Molecule CI workflow for Ubuntu 22.04 GitHub Actions. 2022-12-06 18:24:15 -06:00
Jeff Geerling f2690e01fc
Merge pull request #235 from podarok/patch-1
fix: To have longer timeout for CloudFlare upload
2022-09-09 09:47:45 -05:00
Andrii Podanenko cd0a5f5a90
fix: Review comments 2022-09-09 17:32:16 +03:00
Andrii Podanenko 75c34686a7
fix: To have longer timeout for CSV upload 2022-09-09 14:51:42 +03:00
Perriguey Thomas fe4dfd9ed7 Handle alma linux 2022-08-24 16:44:51 +02:00
Jeff Geerling 500c28789b
Merge pull request #234 from dtourde-dd/fix/handler-launched-if-nginx-status-stopped
fix(handler):not run handler when nginx_service_state stopped
2022-08-04 11:33:04 -05:00
Damien TOURDE d05e5024d7
fix(handler):add condition to not launch handler when nginx_service_state stopped 2022-08-04 13:23:21 +02:00
Jeff Geerling e4a2b6300a Add role_name_check skipping to all molecule test suites. 2022-06-01 22:21:13 -05:00
Jeff Geerling efe506da2b
Merge pull request #232 from XaTTa6bl4/master
change fixed apt package name to var nginx_package_name
2022-04-23 20:33:07 -05:00
XaTTa6bl4 ecd9d2e697 tasks/setup-Ubuntu.yml: change fixed apt package name to var nginx_package_name 2022-04-23 15:53:24 +03:00
Jeff Geerling e1269f9a16 Update release workflow for more consistency. 2021-12-27 11:35:36 -06:00
Jeff Geerling 4387e27a08 Use rockylinux8 instead of centos8 for CI. 2021-12-27 11:30:37 -06:00
Jeff Geerling 179f26a45f
Merge pull request #227 from racke/pr/access_log_discrepancy
Fix discrepancy between README and defaults for nginx_access_log variable
2021-10-17 22:36:22 -05:00
Stefan Hornburg (Racke) 2c430d34ac
Fix discrepancy between README and defaults for nginx_access_log_variable. 2021-10-17 15:22:48 +02:00
Jeff Geerling 552382318b Make sure bugs aren't automatically closed. 2021-08-23 08:53:46 -05:00
Jeff Geerling ce3d3357b0
Merge pull request #222 from glaszig/rocky-linux-support
rocky linux support
2021-07-05 11:27:01 -05:00
glaszig cbf2aea6fe
add rocky linux to ci build matrix 2021-07-04 00:48:45 -03:00
glaszig 9f1b7e9ce7
run redhat tasks on rocky linux 2021-07-03 23:44:20 -03:00
glaszig cee3ac6eed
add vars file for rocky linux 2021-07-03 23:42:38 -03:00
Jeff Geerling 48633acdae
Merge pull request #205 from mtlynch/upstream-servers
Fix documented example value for nginx_upstreams.servers
2021-05-26 17:31:21 -05:00
Jeff Geerling 1820e90b4c PR #86 follow-up: Fix a couple code style issues. 2021-04-13 22:37:05 -05:00
Jeff Geerling e533fbab36
Merge pull request #125 from robbyoconnor/add-ipv6-support
Add ipv6 support
2021-04-13 22:35:16 -05:00
Robert O'Connor 2aa9dd5f06
Fixes #86 -- Add ipv6 support 2021-04-13 00:06:36 -04:00
Jeff Geerling d3baaf9908 Remove ansible-lint from roles. 2021-03-15 09:28:33 -05:00
Jeff Geerling f91f3dc631 Make ansible-lint work again. 2021-02-22 16:15:09 -06:00
Jeff Geerling 3e0b830f84 Drop support for RedHat / CentOS 6. 2020-12-08 17:04:48 -06:00
Jeff Geerling 28c3d9458d Dump Travis CI and move to GitHub Actions. 2020-11-05 15:05:48 -06:00
Jeff Geerling 73b0585715 Switch to travis-ci.com. 2020-10-26 20:10:55 -05:00
Jeff Geerling 2e07c1cae4 Make sure docker driver is installed with molecule. 2020-10-15 17:04:41 -05:00
Jeff Geerling 227d1326ca Fix rule 208 lint issues. 2020-08-20 22:37:17 -05:00
Jeff Geerling 78c46c4972 Ignore the tyranny of ansible-lint rule 106. 2020-08-20 19:22:25 -05:00
Jeff Geerling 485cc835f1 Upgrade Travis CI docker version to fix Molecule tests. 2020-08-12 14:55:29 -05:00
Michael Lynch 2fde446202 Fix documented example value for nginx_upstreams.servers
This converts the example value of nginx_upstreams.servers to a simple list of backends instead of using the unusual object syntax.
2020-08-09 09:12:11 -04:00
Jeff Geerling 9ae8584281 Clarify that PPA addition only happens if configured. 2020-07-22 12:27:50 -05:00
Jeff Geerling c5d73ace87 Ensure dirmngr is installed for gnupg compatibility. 2020-07-22 09:06:49 -05:00
Jeff Geerling 14bda8108e Update nginx test environments. 2020-07-22 09:04:35 -05:00
Jeff Geerling 606592e05e Ensure galaxy meta information is consistent on all my roles. 2020-05-26 09:46:12 -05:00
Jeff Geerling 87ecb1127f Add probot/stale configuration to repository for stale issues. 2020-03-05 10:44:28 -06:00
Jeff Geerling fc5451b2aa Make sure molecule lint script has set -e option. 2020-02-24 09:45:01 -06:00
Jeff Geerling 9fd6f2973b Update molecule configuration to work with 3.0. 2020-02-20 15:54:50 -06:00
Jeff Geerling 790e82457a Update molecule configuration to work with 3.0. 2020-02-20 14:28:57 -06:00
Jeff Geerling 762500858b Update molecule configuration to work with 3.0. 2020-02-20 14:22:55 -06:00
Jeff Geerling 8fd368cea5 YAML syntax fix. 2019-12-11 10:52:50 -06:00
Jeff Geerling f44af7cd88
Create FUNDING.yml 2019-12-11 09:58:20 -06:00
Jeff Geerling 4400af5065
Merge pull request #188 from dbaio/master
Add ASSUME_ALWAYS_YES in FreeBSD pkg update
2019-08-26 14:59:45 -05:00
Danilo G. Baio (dbaio) cac5b664b6 Add quotes to ASSUME_ALWAYS_YES=yes
Prevent YAML interpreters to convert it to bool.
2019-08-26 14:42:33 -03:00
Danilo G. Baio (dbaio) 4e3911c8ea yamllint: Ignore truthy warning for ASSUME_ALWAYS_YES=yes 2019-06-29 09:51:10 -03:00
Danilo G. Baio (dbaio) 654229e203 Add ASSUME_ALWAYS_YES in FreeBSD pkg update 2019-06-27 21:15:00 -03:00
24 changed files with 256 additions and 62 deletions

3
.ansible-lint Normal file
View File

@ -0,0 +1,3 @@
skip_list:
- 'yaml'
- 'role-name'

4
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,4 @@
# These are supported funding model platforms
---
github: geerlingguy
patreon: geerlingguy

68
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,68 @@
---
name: CI
'on':
pull_request:
push:
branches:
- master
schedule:
- cron: "0 6 * * 3"
defaults:
run:
working-directory: 'geerlingguy.nginx'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
path: 'geerlingguy.nginx'
- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install test dependencies.
run: pip3 install yamllint
- name: Lint code.
run: |
yamllint .
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
distro:
- rockylinux9
- ubuntu2204
- debian12
- opensuseleap15
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
path: 'geerlingguy.nginx'
- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install test dependencies.
run: pip3 install ansible molecule molecule-plugins[docker] docker
- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}

40
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,40 @@
---
# This workflow requires a GALAXY_API_KEY secret present in the GitHub
# repository or organization.
#
# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy
# See: https://github.com/ansible/galaxy/issues/46
name: Release
'on':
push:
tags:
- '*'
defaults:
run:
working-directory: 'geerlingguy.nginx'
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
path: 'geerlingguy.nginx'
- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Ansible.
run: pip3 install ansible-core
- name: Trigger a new import on Galaxy.
run: >-
ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }}
$(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)

34
.github/workflows/stale.yml vendored Normal file
View File

@ -0,0 +1,34 @@
---
name: Close inactive issues
'on':
schedule:
- cron: "55 18 * * 6" # semi-random time
jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v8
with:
days-before-stale: 120
days-before-close: 60
exempt-issue-labels: bug,pinned,security,planned
exempt-pr-labels: bug,pinned,security,planned
stale-issue-label: "stale"
stale-pr-label: "stale"
stale-issue-message: |
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale.
close-issue-message: |
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
stale-pr-message: |
This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale.
close-pr-message: |
This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
repo-token: ${{ secrets.GITHUB_TOKEN }}

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
*.retry
*/__pycache__
*.pyc
.cache
venv/
.vscode/

View File

@ -1,29 +0,0 @@
---
language: python
services: docker
env:
global:
- ROLE_NAME: nginx
matrix:
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: debian9
install:
# Install test dependencies.
- pip install molecule docker
before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME
- cd geerlingguy.$ROLE_NAME
script:
# Run tests.
- molecule test
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@ -1,6 +1,10 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
ignore: |
.github/workflows/stale.yml

View File

@ -1,6 +1,6 @@
# Ansible Role: Nginx
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-nginx)
[![CI](https://github.com/geerlingguy/ansible-role-nginx/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-nginx/actions?query=workflow%3ACI)
**Note:** Please consider using the official [NGINX Ansible role](https://github.com/nginxinc/ansible-role-nginx) from NGINX, Inc.
@ -16,6 +16,11 @@ None.
Available variables are listed below, along with default values (see `defaults/main.yml`):
nginx_listen_ipv6: true
Whether or not to listen on IPv6 (applied to all vhosts managed by this role).
nginx_vhosts: []
A list of vhost definitions (server blocks) for Nginx virtual hosts. Each entry will create a separate config file named by `server_name`. If left empty, you will need to supply your own virtual host configuration. See the commented example in `defaults/main.yml` for available server options. If you have a large number of customizations required for your server definition(s), you're likely better off managing the vhost configuration file yourself, leaving this variable set to `[]`.
@ -77,7 +82,7 @@ The user under which Nginx will run. Defaults to `nginx` for RedHat, `www-data`
`nginx_worker_processes` should be set to the number of cores present on your machine (if the default is incorrect, find this number with `grep processor /proc/cpuinfo | wc -l`). `nginx_worker_connections` is the number of connections per process. Set this higher to handle more simultaneous connections (and remember that a connection will be used for as long as the keepalive timeout duration for every client!). You can set `nginx_multi_accept` to `on` if you want Nginx to accept all connections immediately.
nginx_error_log: "/var/log/nginx/error.log warn"
nginx_access_log: "/var/log/nginx/access.log main buffer=16k"
nginx_access_log: "/var/log/nginx/access.log main buffer=16k flush=2m"
Configuration of the default error and access logs. Set to `off` to disable a log entirely.
@ -150,6 +155,10 @@ Configures Nginx's [`log_format`](http://nginx.org/en/docs/http/ngx_http_log_mod
(For RedHat/CentOS only) Set this to `false` to disable the installation of the `nginx` yum repository. This could be necessary if you want the default OS stable packages, or if you use Satellite.
nginx_zypper_repo_enabled: true
(For Suse only) Set this to `false` to disable the installation of the `nginx` zypper repository. This could be necessary if you want the default OS stable packages, or if you use Suse Manager.
nginx_service_state: started
nginx_service_enabled: yes

View File

@ -5,6 +5,9 @@ nginx_default_release: ""
# Used only for Redhat installation, enables source Nginx repo.
nginx_yum_repo_enabled: true
# Used only for Suse installation, enables source Nginx repo.
nginx_zypper_repo_enabled: true
# Use the official Nginx PPA for Ubuntu, and the version to use if so.
nginx_ppa_use: false
nginx_ppa_version: stable
@ -30,8 +33,8 @@ nginx_sendfile: "on"
nginx_tcp_nopush: "on"
nginx_tcp_nodelay: "on"
nginx_keepalive_timeout: "65"
nginx_keepalive_requests: "100"
nginx_keepalive_timeout: "75"
nginx_keepalive_requests: "600"
nginx_server_tokens: "on"
@ -57,6 +60,10 @@ nginx_extra_http_options: ""
# proxy_set_header Host $http_host;
nginx_remove_default_vhost: false
# Listen on IPv6 (default: true)
nginx_listen_ipv6: true
nginx_vhosts: []
# Example vhost below, showing all available options:
# - listen: "80" # default: "80"
@ -78,11 +85,10 @@ nginx_upstreams: []
# - name: myapp1
# strategy: "ip_hash" # "least_conn", etc.
# keepalive: 16 # optional
# servers: {
# "srv1.example.com",
# "srv2.example.com weight=3",
# "srv3.example.com"
# }
# servers:
# - "srv1.example.com"
# - "srv2.example.com weight=3"
# - "srv3.example.com"
nginx_log_format: |-
'$remote_addr - $remote_user [$time_local] "$request" '

View File

@ -8,3 +8,4 @@
- name: reload nginx
service: name=nginx state=reloaded
when: nginx_service_state == "started"

View File

@ -2,16 +2,13 @@
dependencies: []
galaxy_info:
role_name: nginx
author: geerlingguy
description: Nginx installation for Linux, FreeBSD and OpenBSD.
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.4
min_ansible_version: 2.10
platforms:
- name: EL
versions:
- 6
- 7
- name: Debian
versions:
- all
@ -19,6 +16,7 @@ galaxy_info:
versions:
- trusty
- xenial
- focal
- name: Archlinux
versions:
- all

View File

@ -1,29 +1,21 @@
---
role_name_check: 1
dependency:
name: galaxy
options:
ignore-errors: true
driver:
name: docker
lint:
name: yamllint
options:
config-file: molecule/default/yaml-lint.yml
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
converge: ${MOLECULE_PLAYBOOK:-converge.yml}

View File

@ -10,7 +10,7 @@
# Setup/install tasks.
- include_tasks: setup-RedHat.yml
when: ansible_os_family == 'RedHat'
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Rocky' or ansible_os_family == 'AlmaLinux'
- include_tasks: setup-Ubuntu.yml
when: ansible_distribution == 'Ubuntu'
@ -27,6 +27,9 @@
- include_tasks: setup-Archlinux.yml
when: ansible_os_family == 'Archlinux'
- include_tasks: setup-Suse.yml
when: ansible_os_family == 'Suse'
# Vhost configuration.
- import_tasks: vhosts.yml

View File

@ -1,6 +1,8 @@
---
- name: Update pkg cache.
command: pkg update -f
environment:
ASSUME_ALWAYS_YES: "yes"
tags: ['skip_ansible_lint']
- name: Ensure nginx is installed.
@ -12,3 +14,4 @@
file:
path: /var/log/nginx
state: directory
mode: 0755

View File

@ -8,3 +8,4 @@
file:
path: /var/log/nginx
state: directory
mode: 0755

14
tasks/setup-Suse.yml Normal file
View File

@ -0,0 +1,14 @@
---
- name: Enable nginx repo.
zypper_repository:
name: nginx
repo: http://nginx.org/packages/sles/{{ ansible_distribution_major_version }}
state: present
disable_gpg_check: true
autorefresh: true
when: nginx_zypper_repo_enabled | bool
- name: Ensure nginx is installed.
package:
name: "{{ nginx_package_name }}"
state: present

View File

@ -1,5 +1,10 @@
---
- name: Add PPA for Nginx.
- name: Ensure dirmngr is installed (gnupg dependency).
apt:
name: dirmngr
state: present
- name: Add PPA for Nginx (if configured).
apt_repository:
repo: 'ppa:nginx/{{ nginx_ppa_version }}'
state: present
@ -9,7 +14,7 @@
- name: Ensure nginx will reinstall if the PPA was just added.
apt:
name: nginx
name: "{{ nginx_package_name }}"
state: absent
when: nginx_ppa_added.changed
when: nginx_ppa_added is changed
tags: ['skip_ansible_lint']

View File

@ -10,6 +10,7 @@
file:
path: "{{ nginx_vhost_path }}"
state: directory
mode: 0755
notify: reload nginx
- name: Add managed vhost config files.

View File

@ -2,6 +2,9 @@
{% if item.server_name_redirect is defined %}
server {
listen {{ item.listen | default('80') }};
{% if nginx_listen_ipv6 %}
listen [::]:{{item.listen | default('80') }};
{% endif %}
server_name {{ item.server_name_redirect }};
return 301 $scheme://{{ item.server_name.split(' ')[0] }}$request_uri;
}
@ -13,6 +16,9 @@ server {
{% block server_basic -%}
listen {{ item.listen | default('80') }};
{% if nginx_listen_ipv6 %}
listen [::]:{{item.listen | default('80') }};
{% endif %}
{% if item.server_name is defined %}
server_name {{ item.server_name }};

9
vars/AlmaLinux.yml Normal file
View File

@ -0,0 +1,9 @@
---
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
__nginx_user: "nginx"

9
vars/Rocky.yml Normal file
View File

@ -0,0 +1,9 @@
---
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
__nginx_user: "nginx"

9
vars/Suse.yml Normal file
View File

@ -0,0 +1,9 @@
---
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
__nginx_user: "nginx"