From dd24f020a9b6485269a80fd5656880c7212cb4d1 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Fri, 18 May 2018 23:47:47 +0200 Subject: [PATCH] Handle undefined type attribute This fixes this exception (issue #40): [WARNING]: exception: Traceback (most recent call last): File "/tmp/ansible_FfjjGk/ansible_module_network_connections.py", line 2812, in cmd.run() File "/tmp/ansible_FfjjGk/ansible_module_network_connections.py", line 2398, in run self.run_prepare() File "/tmp/ansible_FfjjGk/ansible_module_network_connections.py", line 2653, in run_prepare if connection['type'] in [ 'macvlan' ]: KeyError: 'type' --- library/network_connections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/network_connections.py b/library/network_connections.py index efcc9a6..14e3d96 100644 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -2673,7 +2673,7 @@ class Cmd_initscripts(Cmd): def run_prepare(self): Cmd.run_prepare(self) for idx, connection in enumerate(self.connections): - if connection['type'] in [ 'macvlan' ]: + if connection.get('type') in [ 'macvlan' ]: self.log_fatal(idx, 'unsupported type %s for initscripts provider' % (connection['type'])) def check_name(self, idx, name = None):