Skip to content

Commit

Permalink
fix: kill dhclient process when interface was dhcp
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed May 8, 2023
1 parent ebfed94 commit 9f84c1d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/module_utils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,17 @@ 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)

Expand Down

0 comments on commit 9f84c1d

Please sign in to comment.