Skip to content

Commit

Permalink
Modified formula to work more seamlessly with salt-ssh. See: saltstac…
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Poage committed Aug 17, 2017
1 parent 27bbc50 commit f9b1058
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 29 deletions.
6 changes: 0 additions & 6 deletions vhusbd/cpuarch_map.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions vhusbd/defaults.yaml

This file was deleted.

48 changes: 43 additions & 5 deletions vhusbd/map.jinja
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@
{% import_yaml "vhusbd/defaults.yaml" as default_settings %}
{% import_yaml "vhusbd/cpuarch_map.yaml" as binary_arch_map %}
{% set vhusbd_binary_arch_map = {
'server': {
'i386': 'vhusbdi386',
'amd64': 'vhusbdx86_64',
'armv6l': 'vhusbdarmpi',
'armv7l': 'vhusbdarmpi2',
},
} %}

{% set default_settings = {
'server': {
'run_as_service': True,
'log_file': '/var/log/vhusbd.log',
'binary': {
'install_dir': '/usr/sbin',
'user': 'root',
'group': 'root',
'mode': 755,
'source': {
'base': 'https://www.virtualhere.com/sites/default/files/usbserver/',
'name': False,
},
},
'config': {
'path': '/etc/vhusbd.conf',
'user': 'root',
'group': 'root',
'mode': 644,
'source': 'salt://vhusbd/files/server/vhusbd.conf',
},
},
} %}

{# get the name of the binary based on the CPU architecture #}
{% set server_arch_source = binary_arch_map.vhusbd_binary_arch_map.server.get(grains['cpuarch'], 'vhusbdi386') %}
{% do default_settings.vhusbd.server.binary.source.update({'name': server_arch_source}) %}
{% if (grains['cpuarch'] == 'armv7l') and ('crc32' in grains['cpu_flags']) %}
{# Raspberry Pi 2 and 3 both report as armv7l currently, but only model 3 has the crc32 cpu flag #}
{% set server_binary_source = 'vhusbdarmpi3' %}
{% else %}
{# for everything not a Pi3, use the CPU arch map to determine the binary name #}
{% set server_binary_source = vhusbd_binary_arch_map.server.get(grains['cpuarch'], 'vhusbdi386') %}
{% endif %}

{# update the default settings map with the binary name determined above #}
{% do default_settings.server.binary.source.update({'name': server_binary_source}) %}

{% set vhusbd = salt['pillar.get']('vhusbd', default=default_settings.vhusbd, merge=True) %}
{% set vhusbd = salt['pillar.get']('vhusbd', default=default_settings, merge=True) %}

0 comments on commit f9b1058

Please sign in to comment.