Skip to content

Commit

Permalink
Merge pull request #54067 from Natrinicle/add-accept-ra-option
Browse files Browse the repository at this point in the history
Adding accept_ra 2 option to modules.debian_ip
  • Loading branch information
dwoz authored Aug 23, 2019
2 parents ba91a1e + ac68148 commit 37ceccb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion salt/modules/debian_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def __space_delimited_list(value):
'dhcp': __within([0, 1], dtype=int),
# inet6 static & manual & dhcp
'media': __anything,
'accept_ra': __within([0, 1], dtype=int),
'accept_ra': __within([0, 1, 2], dtype=int),
'autoconf': __within([0, 1], dtype=int),
'preferred-lifetime': __int,
'dad-attempts': __int, # 0 to disable
Expand Down
5 changes: 3 additions & 2 deletions salt/templates/debian_ip/debian_eth.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'pre_down_cmds': 'pre-down',
'post_down_cmds': 'post-down',
'master': 'bond-master',
'accept_ra': 'accept_ra',
} -%}
{% set concat_opts = ['dns_nameservers'] -%}
{% set valid_opts = [
Expand All @@ -16,14 +17,14 @@
'vendor', 'client', 'bootfile', 'server', 'mode', 'endpoint', 'dstaddr', 'local', 'ttl', 'mtu',
'provider', 'unit', 'options', 'master', 'dns_nameservers', 'wireless_mode', 'wpa_ap_scan',
'wpa_conf', 'wpa_driver', 'wpa_group', 'wpa_key_mgmt', 'wpa_pairwise', 'wpa_proto', 'wpa_psk',
'wpa_roam', 'wpa_ssid',
'wpa_roam', 'wpa_ssid', 'accept_ra'
] -%}
{% if data.enabled %}auto {{ name }}
{% endif %}{% if data.hotplug %}allow-hotplug {{ name }}
{% endif %}{% for inet in ['inet', 'inet6'] -%}
{% if data.data[inet] and data.data[inet].addrfam == inet %}{% set interface = data.data[inet] -%}
{% if interface.proto and interface.addrfam %}iface {{name}} {{interface.addrfam}} {{interface.proto}}
{% for opt in valid_opts %}{% set debopt = optmap.get(opt, opt).replace('_', '-') -%}
{% for opt in valid_opts %}{% set debopt = optmap.get(opt, opt.replace('_', '-')) -%}
{% set val = interface.get(opt, False) %}{% if val -%}
{% if opt in concat_opts and val is iterable %} {{ debopt }} {{ val|join(' ') }}
{% elif val is string or val is number %} {{ debopt }} {{ val }}
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/modules/test_debian_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,37 @@
' address 2001:db8:dead:c0::3/64\n',
' gateway 2001:db8:dead:c0::1\n',
'\n']},

# IPv6-only; static with autoconf and accept_ra forced
{'iface_name': 'eth20', 'iface_type': 'eth', 'enabled': True,
'build_interface': {
'ipv6proto': 'static',
'ipv6ipaddr': '2001:db8:dead:beef::3/64',
'ipv6gateway': '2001:db8:dead:beef::1',
'enable_ipv6': True,
'autoconf': 1,
'accept_ra': 2,
'noifupdown': True,
},
'get_interface': odict([('eth20', odict([('enabled', True), ('data', odict([
('inet6', odict([
('addrfam', 'inet6'),
('proto', 'static'),
('filename', None),
('autoconf', 1),
('address', '2001:db8:dead:beef::3/64'),
('gateway', '2001:db8:dead:beef::1'),
('accept_ra', 2),
])),
]))]))]),
'return': [
'auto eth20\n',
'iface eth20 inet6 static\n',
' autoconf 1\n',
' address 2001:db8:dead:beef::3/64\n',
' gateway 2001:db8:dead:beef::1\n',
' accept_ra 2\n',
'\n']},
]


Expand Down

0 comments on commit 37ceccb

Please sign in to comment.