diff --git a/bundles/nginx/files/arch-override.conf b/bundles/nginx/files/arch-override.conf new file mode 100644 index 0000000..5496fe6 --- /dev/null +++ b/bundles/nginx/files/arch-override.conf @@ -0,0 +1,9 @@ +[Service] +ExecStart= +ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf + +ExecReload= +ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)" + +ExecStop= +ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)" diff --git a/bundles/nginx/files/nginx.conf b/bundles/nginx/files/nginx.conf index 153dc96..19dfcd3 100644 --- a/bundles/nginx/files/nginx.conf +++ b/bundles/nginx/files/nginx.conf @@ -1,4 +1,4 @@ -user www-data; +user ${username}; worker_processes ${worker_processes}; pid /var/run/nginx.pid; diff --git a/bundles/nginx/items.py b/bundles/nginx/items.py index 4c42991..ecfe3ae 100644 --- a/bundles/nginx/items.py +++ b/bundles/nginx/items.py @@ -1,3 +1,10 @@ +if node.has_bundle('pacman'): + package = 'pkg_pacman:nginx' + username = 'http' +else: + package = 'pkg_apt:nginx' + username = 'www-data' + directories = { '/etc/nginx/sites': { 'purge': True, @@ -17,7 +24,10 @@ directories = { files = { '/etc/nginx/nginx.conf': { 'content_type': 'mako', - 'context': node.metadata['nginx'], + 'context': { + 'username': username, + **node.metadata['nginx'], + }, 'triggers': { 'svc_systemd:nginx:restart', }, @@ -42,6 +52,14 @@ files = { 'mode': '0755', }, } +if node.has_bundle('pacman'): + files['/etc/systemd/system/nginx.service.d/bundlewrap.conf'] = { + 'source': 'arch-override.conf', + 'triggers': { + 'action:systemd-reload', + 'svc_systemd:nginx:restart', + }, + } actions = { 'nginx-generate-dhparam': { @@ -54,7 +72,7 @@ svc_systemd = { 'nginx': { 'needs': { 'action:nginx-generate-dhparam', - 'pkg_apt:nginx', + package, }, }, } diff --git a/bundles/nginx/metadata.py b/bundles/nginx/metadata.py index c83ddea..2432f42 100644 --- a/bundles/nginx/metadata.py +++ b/bundles/nginx/metadata.py @@ -33,6 +33,11 @@ defaults = { 'nginx': { 'worker_connections': 768, }, + 'pacman': { + 'packages': { + 'nginx': {}, + }, + }, } if node.has_bundle('telegraf'):