From d16c4b214416d73622fc3b11a378ffcad9ab3ed6 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 8 Mar 2016 14:33:53 +0100 Subject: [PATCH] Added state for /etc/resolv.conf --- basic/files/dhcp-nodnsupdate | 6 ++++++ basic/files/resolv.conf | 9 +++++++++ basic/pkgs.sls | 1 + basic/resolver.sls | 38 ++++++++++++++++++++++++++++++++++++ top.sls | 1 + 5 files changed, 55 insertions(+) create mode 100644 basic/files/dhcp-nodnsupdate create mode 100644 basic/files/resolv.conf create mode 100644 basic/resolver.sls diff --git a/basic/files/dhcp-nodnsupdate b/basic/files/dhcp-nodnsupdate new file mode 100644 index 0000000..9f5c98d --- /dev/null +++ b/basic/files/dhcp-nodnsupdate @@ -0,0 +1,6 @@ +#!/bin/sh + +# Don't overwrite /etc/resolv.conf +make_resolv_conf() { + : +} diff --git a/basic/files/resolv.conf b/basic/files/resolv.conf new file mode 100644 index 0000000..81d00b5 --- /dev/null +++ b/basic/files/resolv.conf @@ -0,0 +1,9 @@ +{%- set domain = salt['pillar.get']('resolver:domain', 'uhu-banane.de') -%} +{%- set search = salt['pillar.get']('resolver:search', ['uhu-banane.de', 'brehm-online.com']) -%} +{%- set def_ns = salt['pillar.get']('resolver:default-nameserver', ['8.8.8.8', '8.8.4.4']) -%} +{%- set nameservers = salt['pillar.get']('resolver:nameserver', def_ns) -%} +domain {{ domain }} +search {{ search|join(' ') }} +{%- for ns in nameservers %} +nameserver {{ ns }} +{%- endfor %} diff --git a/basic/pkgs.sls b/basic/pkgs.sls index 0475bfb..e23446b 100644 --- a/basic/pkgs.sls +++ b/basic/pkgs.sls @@ -1,6 +1,7 @@ common-pkgs: pkg.installed: - pkgs: + - ack-grep - acl - apticron - aptitude diff --git a/basic/resolver.sls b/basic/resolver.sls new file mode 100644 index 0000000..d6bfc91 --- /dev/null +++ b/basic/resolver.sls @@ -0,0 +1,38 @@ + +symlinked-resolv-conf: + cmd.run: + - name: rm -f /etc/resolv.conf + - onlyif: + - test -L /etc/resolv.conf + +/etc/dhcp/dhclient-enter-hooks.d: + file.directory: + - user: root + - group: root + - dir_mode: 755 + - file_mode: 644 + - makedirs: True + +/etc/dhcp/dhclient-enter-hooks.d/nodnsupdate: + file.managed: + - source: salt://basic/files/dhcp-nodnsupdate + - user: root + - group: root + - mode: 644 + - template: jinja + - backup: minion + - require: + - file: /etc/dhcp/dhclient-enter-hooks.d + + +/etc/resolv.conf: + file.managed: + - source: salt://basic/files/resolv.conf + - user: root + - group: root + - mode: 644 + - template: jinja + - backup: minion + - require: + - cmd: symlinked-resolv-conf + - file: /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate diff --git a/top.sls b/top.sls index 5dee2ae..cc5080e 100644 --- a/top.sls +++ b/top.sls @@ -2,6 +2,7 @@ base: 'ns\d+.uhu-banane.de': - match: pcre - debian.apt + - basic.resolver - basic.editors - basic.localization - debian.sysvinit -- 2.39.5