Support the nginx.org PPA and its modules.

This commit is contained in:
Andrea Dell'Amico 2021-05-27 19:41:22 +02:00
parent 44ce326600
commit db109326d8
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
4 changed files with 81 additions and 5 deletions

View File

@ -2,7 +2,15 @@
nginx_enabled: True nginx_enabled: True
nginx_use_ppa: False nginx_use_ppa: False
nginx_ppa_repo: ppa:nginx/stable nginx_ppa_repo: ppa:nginx/stable
nginx_use_nginx_com_repo: False
nginx_com_repo_key: 'https://nginx.org/keys/nginx_signing.key'
nginx_com_repo: 'deb http://nginx.org/packages/ubuntu/ bionic nginx'
nginx_package_state: present nginx_package_state: present
nginx_com_modules: []
# - pkg_name: nginx-module-njs
# mod_name: ngx_http_js_module.so
# enabled: yes
# See https://mozilla.github.io/server-side-tls/ssl-config-generator/ # See https://mozilla.github.io/server-side-tls/ssl-config-generator/
nginx_ssl_level: intermediate nginx_ssl_level: intermediate

View File

@ -22,6 +22,44 @@
with_items: '{{ nginx_conf_snippets }}' with_items: '{{ nginx_conf_snippets }}'
notify: Reload nginx notify: Reload nginx
- name: Create the modules- directories
file:
dest: '/etc/nginx/modules-{{ item }}'
state: directory
loop:
- available
- enabled
- name: Install the modules configurations
copy:
content: "load_module modules/{{ item.mod_name }};"
dest: /etc/nginx/modules-available/{{ item.pkg_name }}.conf
loop: '{{ nginx_com_modules }}'
when:
- item.enabled
- nginx_use_nginx_com_repo
- name: Enable the additional modules
file:
src: /etc/nginx/modules-available/{{ item.pkg_name }}.conf
dest: /etc/nginx/modules-enabled/{{ item.pkg_name }}.conf
state: link
when: item.enabled
loop: '{{ nginx_com_modules }}'
- name: Disable the additional modules that we do not want installed
file:
dest: /etc/nginx/modules-enabled/{{ item.pkg_name }}.conf
state: absent
when: not item.enabled
loop: '{{ nginx_com_modules }}'
- name: Remove the default configuration when using the nginx.com repository
file:
dest: /etc/nginx/conf.d/default.conf
state: absent
when: nginx_use_nginx_com_repo
- name: Install the main nginx.conf - name: Install the main nginx.conf
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf mode=444 template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf mode=444
notify: Reload nginx notify: Reload nginx

View File

@ -4,9 +4,28 @@
apt_repository: repo='{{ nginx_ppa_repo }}' update_cache=yes apt_repository: repo='{{ nginx_ppa_repo }}' update_cache=yes
when: when:
- nginx_use_ppa - nginx_use_ppa
- "'{{ ansible_distribution }}' == 'Ubuntu'" - ansible_distribution == 'Ubuntu'
tags: [ 'nginx', 'nginx_ppa' ] tags: [ 'nginx', 'nginx_ppa' ]
- name: Install the key of the nginx.com repository
apt_key:
url: '{{ nginx_com_repo_key }}'
state: present
when:
- nginx_use_nginx_com_repo
- ansible_distribution == 'Ubuntu'
tags: [ 'nginx', 'nginx_com_ppa' ]
- name: Install the nginx.com repository configuration
apt_repository:
repo: '{{ nginx_com_repo }}'
update_cache: yes
filename: nginx_com
when:
- nginx_use_nginx_com_repo
- ansible_distribution == 'Ubuntu'
tags: [ 'nginx', 'nginx_com_ppa' ]
- name: Install the nginx web server - name: Install the nginx web server
apt: pkg=nginx-full state={{ nginx_package_state }} cache_valid_time=1800 apt: pkg=nginx-full state={{ nginx_package_state }} cache_valid_time=1800
when: when:
@ -20,8 +39,21 @@
- ansible_distribution_major_version <= '14' - ansible_distribution_major_version <= '14'
- name: Install the nginx web server on Ubuntu >= 16.04 - name: Install the nginx web server on Ubuntu >= 16.04
apt: pkg=nginx state={{ nginx_package_state }} cache_valid_time=1800 apt:
pkg: nginx
state: present
cache_valid_time: 1800
when: ansible_distribution_major_version >= '16' when: ansible_distribution_major_version >= '16'
- name: Install the nginx.com additional modules
apt:
pkg: '{{ item.pkg_name }}'
state: present
cache_valid_time: 1800
loop: '{{ nginx_com_modules }}'
when:
- nginx_use_nginx_com_repo
- ansible_distribution_major_version >= '16'
when: ansible_distribution_file_variety == "Debian" when: ansible_distribution_file_variety == "Debian"
tags: nginx tags: [ nginx ]

View File

@ -1,2 +0,0 @@
---
# vars file for ansible-role-template