Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split maps.jinja #4

Merged
merged 2 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {}