Skip to content

Commit

Permalink
Inline nginx role
Browse files Browse the repository at this point in the history
The Azavea role does not work with Ubuntu 22.04. It tries to add
an nginx PPA which is not required in Jammy.
  • Loading branch information
rajadain committed Jul 2, 2024
1 parent 3d638cb commit 6095ed3
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dependencies:
- { role: "azavea.yarn" }
- { role: "azavea.nodejs", nodejs_version: "{{ app_nodejs_version }}", nodejs_npm_version: "{{ app_nodejs_npm_version }}" }
- { role: "model-my-watershed.celery" }
- { role: "azavea.nginx", nginx_delete_default_site: True }
- { role: "model-my-watershed.nginx", nginx_delete_default_site: True }
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
dependencies:
- { role: "azavea.java" }
- { role: "model-my-watershed.base" }
- { role: "azavea.nginx", nginx_delete_default_site: True }
- { role: "model-my-watershed.nginx", nginx_delete_default_site: True }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
nginx_version: "stable"
nginx_delete_default_site: False
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Restart Nginx
service: name=nginx state=restarted
27 changes: 27 additions & 0 deletions deployment/ansible/roles/model-my-watershed.nginx/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Install Nginx
apt: pkg=nginx-full state=present

- name: Delete default site
file: path=/etc/nginx/sites-enabled/default state=absent
register: delete_default_site
when: nginx_delete_default_site | bool
notify:
- Restart Nginx

- name: Delete default web root
file: path=/var/www/html state=absent
when: nginx_delete_default_site | bool and delete_default_site is changed

- name: Check Nginx Upstart service definition exists
stat: path=/etc/init/nginx.conf
register: nginx_upstart

- name: Configure Nginx log rotation
template: src=logrotate_nginx.j2 dest=/etc/logrotate.d/nginx
when: nginx_upstart.stat.exists

- name: Configure Nginx
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
notify:
- Restart Nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/var/log/nginx/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
service nginx rotate >/dev/null 2>&1
endscript
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
user www-data;
worker_processes {{ ansible_processor_count }};
pid /run/nginx.pid;

events {
worker_connections 768;
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

server_tokens off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
dependencies:
- { role: "model-my-watershed.base" }
- { role: "azavea.nodejs", nodejs_version: "{{ tiler_nodejs_version }}", nodejs_npm_version: "{{ tiler_nodejs_npm_version }}" }
- { role: "azavea.nginx", nginx_delete_default_site: True }
- { role: "model-my-watershed.nginx", nginx_delete_default_site: True }

0 comments on commit 6095ed3

Please sign in to comment.