nmcli: Support gre tunnels (#3262) (#3272)

* Add gre tunnel support

* Add gre tunnel support

* Fix Blank Lines

* Fix unit test
Add changelog fragment

* Update plugins/modules/net_tools/nmcli.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update Docs

* Update plugins/modules/net_tools/nmcli.py

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>

* Update Docs

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
(cherry picked from commit b8a081b9b2)

Co-authored-by: zerotens <zerotens@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-08-26 08:32:37 +02:00 committed by GitHub
parent 7278bdcf9d
commit 15a72418ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 162 additions and 4 deletions

View file

@ -55,7 +55,7 @@ options:
- Type C(generic) is added in Ansible 2.5.
- Type C(infiniband) is added in community.general 2.0.0.
type: str
choices: [ bond, bond-slave, bridge, bridge-slave, dummy, ethernet, generic, infiniband, ipip, sit, team, team-slave, vlan, vxlan, wifi ]
choices: [ bond, bond-slave, bridge, bridge-slave, dummy, ethernet, generic, gre, infiniband, ipip, sit, team, team-slave, vlan, vxlan, wifi ]
mode:
description:
- This is the type of device or network connection that you wish to create for a bond or bridge.
@ -314,16 +314,28 @@ options:
type: str
ip_tunnel_dev:
description:
- This is used with IPIP/SIT - parent device this IPIP/SIT tunnel, can use ifname.
- This is used with GRE/IPIP/SIT - parent device this GRE/IPIP/SIT tunnel, can use ifname.
type: str
ip_tunnel_remote:
description:
- This is used with IPIP/SIT - IPIP/SIT destination IP address.
- This is used with GRE/IPIP/SIT - GRE/IPIP/SIT destination IP address.
type: str
ip_tunnel_local:
description:
- This is used with IPIP/SIT - IPIP/SIT local IP address.
- This is used with GRE/IPIP/SIT - GRE/IPIP/SIT local IP address.
type: str
ip_tunnel_input_key:
description:
- The key used for tunnel input packets.
- Only used when I(type=gre).
type: str
version_added: 3.6.0
ip_tunnel_output_key:
description:
- The key used for tunnel output packets.
- Only used when I(type=gre).
type: str
version_added: 3.6.0
zone:
description:
- The trust level of the connection.
@ -896,6 +908,14 @@ EXAMPLES = r'''
vxlan_local: 192.168.1.2
vxlan_remote: 192.168.1.5
- name: Add gre
community.general.nmcli:
type: gre
conn_name: gre_test1
ip_tunnel_dev: eth0
ip_tunnel_local: 192.168.1.2
ip_tunnel_remote: 192.168.1.5
- name: Add ipip
community.general.nmcli:
type: ipip
@ -1058,6 +1078,8 @@ class Nmcli(object):
self.ip_tunnel_dev = module.params['ip_tunnel_dev']
self.ip_tunnel_local = module.params['ip_tunnel_local']
self.ip_tunnel_remote = module.params['ip_tunnel_remote']
self.ip_tunnel_input_key = module.params['ip_tunnel_input_key']
self.ip_tunnel_output_key = module.params['ip_tunnel_output_key']
self.nmcli_bin = self.module.get_bin_path('nmcli', True)
self.dhcp_client_id = module.params['dhcp_client_id']
self.zone = module.params['zone']
@ -1190,6 +1212,11 @@ class Nmcli(object):
'ip-tunnel.parent': self.ip_tunnel_dev,
'ip-tunnel.remote': self.ip_tunnel_remote,
})
if self.type == 'gre':
options.update({
'ip-tunnel.input-key': self.ip_tunnel_input_key,
'ip-tunnel.output-key': self.ip_tunnel_output_key
})
elif self.type == 'vlan':
options.update({
'vlan.id': self.vlanid,
@ -1247,6 +1274,7 @@ class Nmcli(object):
'dummy',
'ethernet',
'generic',
'gre',
'infiniband',
'ipip',
'sit',
@ -1293,6 +1321,7 @@ class Nmcli(object):
@property
def tunnel_conn_type(self):
return self.type in (
'gre',
'ipip',
'sit',
)
@ -1592,6 +1621,7 @@ def main():
'dummy',
'ethernet',
'generic',
'gre',
'infiniband',
'ipip',
'sit',
@ -1663,6 +1693,9 @@ def main():
ip_tunnel_dev=dict(type='str'),
ip_tunnel_local=dict(type='str'),
ip_tunnel_remote=dict(type='str'),
# ip-tunnel type gre specific vars
ip_tunnel_input_key=dict(type='str', no_log=True),
ip_tunnel_output_key=dict(type='str', no_log=True),
# 802-11-wireless* specific vars
ssid=dict(type='str'),
wifi=dict(type='dict'),