From e744591af4901268c347458626373b6bcb66ae23 Mon Sep 17 00:00:00 2001
From: Dennis Ahrens <dennis.ahrens@hs-hannover.de>
Date: Wed, 4 Dec 2019 10:18:24 +0100
Subject: [PATCH] Make additional entries in /etc/hosts possible using pillar

---
 hshbase/defaults.yaml        | 1 +
 hshbase/hostname/files/hosts | 7 +++++++
 pillar.example               | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/hshbase/defaults.yaml b/hshbase/defaults.yaml
index f8fa2c2..71222b4 100644
--- a/hshbase/defaults.yaml
+++ b/hshbase/defaults.yaml
@@ -14,3 +14,4 @@ hshbase:
   dns:
     - 192.108.52.10
     - 141.71.2.121
+  hosts: {}
diff --git a/hshbase/hostname/files/hosts b/hshbase/hostname/files/hosts
index 20d45e3..394055d 100644
--- a/hshbase/hostname/files/hosts
+++ b/hshbase/hostname/files/hosts
@@ -1,3 +1,6 @@
+{% from "hshbase/map.jinja" import hshbase with context %}
+
+    - pkgs: {{ hshbase.apt.pkgs }}
 ### THIS FILE IS MANAGED BY SALT!
 ### YOUR CHANGES WILL BE OVERWRITTEN!
 127.0.0.1	localhost
@@ -18,3 +21,7 @@ ff02::2 ip6-allrouters
 {{ ip }}	{{ fqdn }} {{ localname }} 
 {%- endif %}
 {%- endfor %}
+
+{% for fqdn, ip in hshbase.hosts.items() %}
+{{ ip }} {{ fqdn }}
+{% endfor %}
diff --git a/pillar.example b/pillar.example
index 3030e09..7832b6e 100644
--- a/pillar.example
+++ b/pillar.example
@@ -4,3 +4,5 @@ hshbase:
     proxy_address: http://apt-proxy.it.hs-hannover.de:8080
     pkgs: [pwgen, tree]
   openvmtools: True
+  hosts:
+    foobar.example.com: 123.45.67.89
-- 
GitLab