diff --git a/plugins/module_utils/interface.py b/plugins/module_utils/interface.py index f2bfb61a..bcd8b0e8 100644 --- a/plugins/module_utils/interface.py +++ b/plugins/module_utils/interface.py @@ -147,9 +147,6 @@ def _params_to_obj(self): else: self.target_elt = self._get_interface_elt_by_display_name(self.obj['descr']) - if self.target_elt is not None: - self.result['ifname'] = self.target_elt.tag - return obj def _validate_params(self): @@ -214,6 +211,7 @@ def _copy_and_add_target(self): """ create the XML target_elt """ self.pfsense.copy_dict_to_element(self.obj, self.target_elt) self.setup_interface_cmds += "interface_configure('{0}', true);\n".format(self.target_elt.tag) + self.result['ifname'] = self.target_elt.tag def _copy_and_update_target(self): """ update the XML target_elt """ @@ -229,6 +227,7 @@ def _copy_and_update_target(self): else: self.setup_interface_cmds += "interface_bring_down('{0}', true);\n".format(self.target_elt.tag) + self.result['ifname'] = self.target_elt.tag return (before, changed) def _create_target(self): @@ -326,6 +325,7 @@ def _pre_remove_target_elt(self): self._remove_all_rules(self.target_elt.tag) self.setup_interface_pre_cmds += "interface_bring_down('{0}');\n".format(self.target_elt.tag) + self.result['ifname'] = self.target_elt.tag def _remove_all_rules(self, interface): """ delete all interface rules """