From e5657adf4b75993528ea72b48ff5510a3ac37919 Mon Sep 17 00:00:00 2001
From: Dennis Ahrens <dennis.ahrens@hs-hannover.de>
Date: Thu, 1 Dec 2022 15:45:00 +0100
Subject: [PATCH] Make nginx optional

---
 README.md            | 10 ++++++----
 postgrest/common.sls |  3 ++-
 postgrest/nginx.sls  |  5 +++++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 44cd40d..ce8ed22 100644
--- a/README.md
+++ b/README.md
@@ -74,8 +74,10 @@ You can access your PostgREST instances at:
 - `apiv2.postgrest.local:4432`
 - `icmscache.postgrest.local:4432`
 
-### SSL certificates
+### nginx
 
-Don't worry about this for the next 10 years.
-Should this still be around and the certificate did expire just generate a new one with the `new_cert.sh` script in `.saltstack/pillar/sslcert/`.
-Make sure to adjust the pillar data (`postrest.sls` in the same directory) with the newly generated data.
+This formula is capable of installing and configuring nginx.
+Therefore you need to have an `nginx` block below your instance configuration as
+you can see in `pillar.example`.
+If you omit this block the formula does not care about nginx.
+This is useful, if you want to use the nginx formula.
diff --git a/postgrest/common.sls b/postgrest/common.sls
index e192eb3..5882dc5 100644
--- a/postgrest/common.sls
+++ b/postgrest/common.sls
@@ -1,3 +1,4 @@
 postgrest_packages:
   pkg.installed:
-    - pkgs: [nginx, postgresql-client]
+    - pkgs:
+      - postgresql-client
diff --git a/postgrest/nginx.sls b/postgrest/nginx.sls
index 823c328..a037103 100644
--- a/postgrest/nginx.sls
+++ b/postgrest/nginx.sls
@@ -1,6 +1,11 @@
 {% for instance_name, instance_conf in salt['pillar.get']("postgrest:instances").items() %}
 {% if instance_conf.nginx is defined %}
 
+postgrest_nginx_package:
+  pkg.installed:
+    - pkgs:
+      - nginx
+
 postgrest_{{ instance_name }}_nginx_conf:
   file.managed:
     - name: /etc/nginx/sites-available/{{ instance_name }}.conf
-- 
GitLab