Browse Source

nginx: Start nginx after network is online

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 5 months ago
parent
commit
9b42a42bf0
2 changed files with 14 additions and 0 deletions
  1. 11 0
      nginx/init.sls
  2. 3 0
      nginx/service-override.conf

+ 11 - 0
nginx/init.sls

@@ -2,6 +2,9 @@
 # Nginx
 #
 
+include:
+ - systemd
+
 {% set node_config = salt['pillar.get']('nodes:' ~ grains.id) %}
 {% set nginx_pkg = node_config.get('nginx:pkg', 'nginx') %}
 {% set acme_thumbprint = salt['pillar.get']('acme:thumbprint') %}
@@ -17,6 +20,14 @@ nginx:
     - watch:
       - cmd: nginx-configtest
 
+# Add dependecy on network-online.target
+/etc/systemd/system/nginx.service.d/override.conf:
+  file.managed:
+    - makedirs: true
+    - source: salt://nginx/service-override.conf
+    - watch_in:
+      - cmd: systemctl-daemon-reload
+
 # Add cache directory
 nginx-cache:
   file.directory:

+ 3 - 0
nginx/service-override.conf

@@ -0,0 +1,3 @@
+[Unit]
+After=network-online.target
+Wants=network-online.target