From b0ea19d03e7102b08b446803daf2d8774efd8670 Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Wed, 28 Nov 2018 12:56:49 +0100 Subject: [PATCH 1/2] Split maps.jinja - into defaults, osfamilymap & osmap. - Added Raspbian support. --- hostapd/defaults.yaml | 11 +++++++++ hostapd/map.jinja | 51 ++++++++++++++-------------------------- hostapd/osfamilymap.yaml | 9 +++++++ hostapd/osmap.yaml | 1 + 4 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 hostapd/defaults.yaml create mode 100644 hostapd/osfamilymap.yaml create mode 100644 hostapd/osmap.yaml diff --git a/hostapd/defaults.yaml b/hostapd/defaults.yaml new file mode 100644 index 0000000..937ecc5 --- /dev/null +++ b/hostapd/defaults.yaml @@ -0,0 +1,11 @@ +hostapd: + pkgs: [] + realtek_pkgs: [] + atheros_pkgs: [] + mode: '600' + user: root + group: root + conf_dir: /etc/hostapd + conf_file: hostapd.conf + service: hostapd + defaults_file: /etc/default/hostapd diff --git a/hostapd/map.jinja b/hostapd/map.jinja index 497ee15..8b5f686 100644 --- a/hostapd/map.jinja +++ b/hostapd/map.jinja @@ -1,34 +1,17 @@ -{% set map = salt['grains.filter_by']({ - 'Debian': { - 'pkgs': ['hostapd', 'iw', 'wireless-tools'], - 'realtek_pkgs': ['firmware-realtek'], - 'atheros_pkgs': ['firmware-atheros'], - 'service': 'hostapd', - 'conf_dir': '/etc/hostapd', - 'conf_file': 'hostapd.conf', - 'user': 'root', - 'group': 'root', - 'mode': '600', - 'defaults_file': '/etc/default/hostapd', - }, - 'Ubuntu': { - 'pkgs': ['hostapd', 'iw', 'wireless-tools'], - 'realtek_pkgs': [], - 'atheros_pkgs': [], - 'service': 'hostapd', - 'conf_dir': '/etc/hostapd', - 'conf_file': 'hostapd.conf', - 'user': 'root', - 'group': 'root', - 'mode': '600', - 'defaults_file': '/etc/default/hostapd', - }, - 'FreeBSD': { - 'service': 'hostapd', - 'conf_dir': '/etc', - 'conf_file': 'hostapd.conf', - 'user': 'root', - 'group': 'wheel', - 'mode': '600', - }, -}, grain='os', merge=salt['pillar.get']('hostapd:lookup')) %} +{% import_yaml "hostapd/defaults.yaml" as defaults %} +{% import_yaml "hostapd/osfamilymap.yaml" as osfamilymap %} +{% import_yaml "hostapd/osmap.yaml" as osmap %} + +{%- set map = salt['grains.filter_by']( + defaults, + merge=salt['grains.filter_by']( + osfamilymap, + grain='os_family', + merge=salt['grains.filter_by']( + osmap, + grain='os', + merge=salt['pillar.get']('hostapd:lookup', {}), + ), + ), + base='hostapd') +%} diff --git a/hostapd/osfamilymap.yaml b/hostapd/osfamilymap.yaml new file mode 100644 index 0000000..75ba0a0 --- /dev/null +++ b/hostapd/osfamilymap.yaml @@ -0,0 +1,9 @@ +Debian: + pkgs: ['hostapd', 'iw', 'wireless-tools'] + realtek_pkgs: ['firmware-realtek'] + atheros_pkgs: ['firmware-atheros'] +Ubuntu: + pkgs: ['hostapd', 'iw', 'wireless-tools'] +FreeBSD: + conf_dir: /etc + group: wheel diff --git a/hostapd/osmap.yaml b/hostapd/osmap.yaml new file mode 100644 index 0000000..863d415 --- /dev/null +++ b/hostapd/osmap.yaml @@ -0,0 +1 @@ +Raspbian: {} From 7dd83b137b7aa246a29686678b3b029c9e4c6996 Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Wed, 28 Nov 2018 13:45:23 +0100 Subject: [PATCH 2/2] Fixed DAEMON_CONF pattern --- hostapd/init.sls | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hostapd/init.sls b/hostapd/init.sls index 67a3e4c..904b262 100644 --- a/hostapd/init.sls +++ b/hostapd/init.sls @@ -22,8 +22,10 @@ hostapd_pkgs: hostapd_activate: file.replace: - name: {{ map.defaults_file }} - - pattern: "^DAEMON_CONF=.*$" + - pattern: "^(|#)DAEMON_CONF=.*$" - repl: "DAEMON_CONF='{% for card in salt['pillar.get']('hostapd:cardlist', {}).keys() %}{{ card2conf(card, map) }} {% endfor %}'" + - watch_in: + - service: hostapd_service {%- endif %} # Ensure hostapd service is running and autostart is enabled