-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefaults.jinja
81 lines (71 loc) · 2.75 KB
/
defaults.jinja
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{% macro netcidr(cidr) %}{{ salt['network.convert_cidr'](cidr)['network'] }}{% endmacro %}
{% macro netmask(cidr) %}{{ salt['network.convert_cidr'](cidr)['netmask'] }}{% endmacro %}
{% macro cidr2ip(cidr) %}{{ cidr|regex_replace ('([^/]+)/.+', '\\1') }}{% endmacro %}
{% macro reverse_net(cidr) %}{{ salt['network.reverse_ip'](netcidr(cidr))|regex_replace('[^.]+\\.(.+)$', '\\1') }}{% endmacro %}
{% macro short_net(cidr) %}{{ cidr2ip(netcidr(cidr))|regex_replace('(.+)\\.[^.]+$', '\\1') }}{% endmacro %}
{% set internal_cidr = salt['pillar.get']('node:network:internal:cidr', '10.140.250.1/24') %}
{% set internal_name = salt['pillar.get']('node:network:internal:name', 'resident') %}
{# defaults #}
{% load_yaml as defaults %}
hostname:
users:
groups:
locale:
lang: en_US.UTF-8
# additional_lang: space seperated list of lang entries (without .UTF-8)
additional_lang: ""
language: en_us:en
# messages: if set, will be written to LC_MESSAGES, eg.: "messages: POSIX"
messages:
# keymap: keymap of keyboard
keymap: us
hypen: en-us
spell: en-us
# time_zone: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
timezone: UTC
# metric for Metric, imperial for Imperial
unit_system: metric
# ### location information
city: World
country_code: UN
# latitude + longitude = Greenwich/UK at sealevel
latitude: 51.47731
longitude: 0
# elevation: Altitude above sea level in meters
elevation: 0
network:
internal:
cidr: {{ internal_cidr }}
name: {{ internal_name }}
# computed if empty: ip, netcidr, netmask, reverse_net, short_net; default priority
netplan:
systemd:
nsswitch:
hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns
priority: 80
storage: {}
{% endload %}
{# merge defaults with pillar #}
{% set settings=salt['grains.filter_by']({'none': defaults},
grain='none', default= 'none', merge= salt['pillar.get']('node', {})) %}
{# update settings.network.internal #}
{% if not settings.network.internal.ip|d(false) %}
{% do settings.network.internal.update(
{'ip': cidr2ip(settings.network.internal.cidr),} ) %}
{% endif %}
{% if not settings.network.internal.netcidr|d(false) %}
{% do settings.network.internal.update(
{'netcidr': netcidr(settings.network.internal.cidr),} ) %}
{% endif %}
{% if not settings.network.internal.netmask|d(false) %}
{% do settings.network.internal.update(
{'netmask': netmask(settings.network.internal.cidr),} ) %}
{% endif %}
{% if not settings.network.internal.reverse_net|d(false) %}
{% do settings.network.internal.update(
{'reverse_net': reverse_net(settings.network.internal.cidr),} ) %}
{% endif %}
{% if not settings.network.internal.short_net|d(false) %}
{% do settings.network.internal.update(
{'short_net': short_net(settings.network.internal.cidr),} ) %}
{% endif %}