Skip to content

Commit

Permalink
Merge pull request #4 from alxwr/master
Browse files Browse the repository at this point in the history
Split maps.jinja
  • Loading branch information
aboe76 authored Feb 12, 2019
2 parents c29f376 + 7dd83b1 commit bef5448
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 35 deletions.
11 changes: 11 additions & 0 deletions hostapd/defaults.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion hostapd/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 17 additions & 34 deletions hostapd/map.jinja
Original file line number Diff line number Diff line change
@@ -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')
%}
9 changes: 9 additions & 0 deletions hostapd/osfamilymap.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions hostapd/osmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raspbian: {}

0 comments on commit bef5448

Please sign in to comment.