diff --git a/plugins/module_utils/interface.py b/plugins/module_utils/interface.py index 08db349e..70ac7c8a 100644 --- a/plugins/module_utils/interface.py +++ b/plugins/module_utils/interface.py @@ -220,9 +220,18 @@ def _copy_and_update_target(self): if changed: if self.params['enable']: self.setup_interface_cmds += "interface_bring_down('{0}', false);\n".format(self.target_elt.tag) + + # possibly kill remaining dhclient process + if 'ipaddr' in before and before['ipaddr'] == 'dhcp': + self.setup_interface_cmds += "kill_dhclient_process(get_real_interface({0}));\n".format(self.target_elt.tag) + + self.setup_interface_cmds += "interface_configure('{0}', true);\n".format(self.target_elt.tag) else: self.setup_interface_cmds += "interface_bring_down('{0}', true);\n".format(self.target_elt.tag) + # possibly kill remaining dhclient process + if 'ipaddr' in before and before['ipaddr'] == 'dhcp': + self.setup_interface_cmds += "kill_dhclient_process(get_real_interface({0}));\n".format(self.target_elt.tag) return (before, changed)