Browse Source

Allow more complex installation in various scenarios

In some distributions package is not wireguard. In older distribution,
kernel module might be in different package. And for some distributions,
additional repositories might be needed and those might depend on
architecture. So making sure all that is possible and adding example
from SUSE family.
tags/v2.1.1
Michal Hrušecký 4 years ago
parent
commit
a2ee53f07b
7 changed files with 168 additions and 6 deletions
  1. +2
    -1
      wireguard/defaults.yaml
  2. +21
    -0
      wireguard/init.sls
  3. +17
    -5
      wireguard/map.jinja
  4. +31
    -0
      wireguard/osarchmap.yaml
  5. +13
    -0
      wireguard/osfamilymap.yaml
  6. +48
    -0
      wireguard/osfingermap.yaml
  7. +36
    -0
      wireguard/osmap.yaml

+ 2
- 1
wireguard/defaults.yaml View File

# vim: ft=yaml # vim: ft=yaml


wireguard: wireguard:
package: wireguard
packages:
- wireguard

+ 21
- 0
wireguard/init.sls View File

{% from "wireguard/map.jinja" import wireguard with context %}

wireguard_software:
pkg.installed:
- pkgs:
{%- for pkg in wireguard.packages %}
- {{ pkg }}
{%- endfor %}
{%- if wireguard.get('repository', False) %}
- require:
- pkgrepo: wireguard_repo

wireguard_repo:
pkgrepo.managed:
{%- for k,v in wireguard.repository.items() %}
- {{ k }}: {{ v }}
{%- endfor %}
{%- endif %}

{%- for interface_name, interface_dict in salt['pillar.get']('wireguard:interfaces', {}).items() %} {%- for interface_name, interface_dict in salt['pillar.get']('wireguard:interfaces', {}).items() %}


{% if interface_dict.get('delete', False) %} {% if interface_dict.get('delete', False) %}
- enable: True - enable: True
- watch: - watch:
- file: wireguard_interface_{{interface_name}}_config - file: wireguard_interface_{{interface_name}}_config
- require:
- pkg: wireguard_software
{% endif %} {% endif %}


{% if interface_dict.get('raw_config') %} {% if interface_dict.get('raw_config') %}

+ 17
- 5
wireguard/map.jinja View File

# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=jinja # vim: ft=jinja


{% import_yaml "wireguard/defaults.yaml" as defaults %}
{#- Start with defaults from defaults.yaml #}
{% import_yaml "wireguard/defaults.yaml" as default_settings %}
{% import_yaml "wireguard/osarchmap.yaml" as osarchmap %}
{% import_yaml "wireguard/osfamilymap.yaml" as osfamilymap %}
{% import_yaml "wireguard/osmap.yaml" as osmap %}
{% import_yaml "wireguard/osfingermap.yaml" as osfingermap %}

{% set wireguard = salt['grains.filter_by'](default_settings,
default='wireguard',
merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
merge=salt['grains.filter_by'](osmap, grain='os',
merge=salt['grains.filter_by'](osfingermap, grain='osfinger',
merge=salt['grains.filter_by'](salt['grains.filter_by'](osarchmap, grain='osfinger'), grain='osarch')
)
)
)
) %}


{% set wireguard = salt['grains.filter_by'](
defaults,
base='wireguard')
%}

+ 31
- 0
wireguard/osarchmap.yaml View File

# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['osarch'] based logic.
# You just need to add the key:values for an `osarch` that differ
# from `defaults.yaml`.
# Only add an `osarch` which is/will be supported by the formula.
#
# If you do not need to provide defaults via the `osarch` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osarch: {}
---
Leap-15:
aarch64:
repository:
name: wireguard
humanname: Wireguard VPN
baseurl: https://download.opensuse.org/repositories/network:/vpn:/wireguard/openSUSE_Leap_15.1_ARM
gpgautoimport: True
gpgkey: https://download.opensuse.org/repositories/network:/vpn:/wireguard/openSUSE_Leap_15.1/repodata/repomd.xml.key
gpgcheck: 1
x86_64:
repository:
name: wireguard
humanname: Wireguard VPN
baseurl: https://download.opensuse.org/repositories/network:/vpn:/wireguard/openSUSE_Leap_15.1
gpgautoimport: True
gpgkey: https://download.opensuse.org/repositories/network:/vpn:/wireguard/openSUSE_Leap_15.1/repodata/repomd.xml.key
gpgcheck: 1
default:
default: {}

+ 13
- 0
wireguard/osfamilymap.yaml View File

# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['os_family'] based logic.
# You just need to add the key:values for an `os_family` that differ
# from `defaults.yaml` + `osarch.yaml`.
# Only add an `os_family` which is/will be supported by the formula.
#
# If you do not need to provide defaults via the `os_family` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osfamilymap: {}
---
default: {}

+ 48
- 0
wireguard/osfingermap.yaml View File

# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['osfinger'] based logic.
# You just need to add the key:values for an `osfinger` that differ
# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml` + `osmap.yaml`.
# Only add an `osfinger` which is/will be supported by the formula.
#
# If you do not need to provide defaults via the `os_finger` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osfingermap: {}
---
# os: Debian
Debian-10: {}
Debian-9: {}
Debian-8: {}

# os: Ubuntu
Ubuntu-18.04: {}
Ubuntu-16.04: {}

# os: Fedora
Fedora-31: {}
Fedora-30: {}

# os: CentOS
CentOS Linux-8: {}
CentOS Linux-7: {}
CentOS-6: {}

# os: Amazon
Amazon Linux-2: {}
Amazon Linux AMI-2018: {}

# os: SUSE
Leap-15:
packages:
- wireguard-tools
- wireguard-kmp-default

# os: FreeBSD
FreeBSD-12: {}

# os: Windows
Windows-8.1: {}

# os: Gentoo
Gentoo-2: {}

+ 36
- 0
wireguard/osmap.yaml View File

# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['os'] based logic.
# You just need to add the key:values for an `os` that differ
# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml`.
# Only add an `os` which is/will be supported by the formula.
#
# If you do not need to provide defaults via the `os` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osmap: {}
---
# os_family: Debian
Ubuntu: {}
Raspbian: {}

# os_family: RedHat
Fedora: {}
CentOS: {}
Amazon: {}

# os_family: Suse
SUSE:
packages:
- wireguard-tools

# os_family: Gentoo
Funtoo: {}

# os_family: Arch
Manjaro: {}

# os_family: Solaris
SmartOS: {}

default: {}

Loading…
Cancel
Save