diff --git a/lib/ansible/modules/system/interfaces_file.py b/lib/ansible/modules/system/interfaces_file.py index 73660832d71..d062b735c70 100755 --- a/lib/ansible/modules/system/interfaces_file.py +++ b/lib/ansible/modules/system/interfaces_file.py @@ -302,6 +302,14 @@ def setInterfaceOption(module, lines, iface, option, raw_value, state): def addOptionAfterLine(option, value, iface, lines, last_line_dict, iface_options): + # Changing method of interface is not an addition + if option == 'method': + for ln in lines: + if ln.get('line_type', '') == 'iface': + ln['line'] = re.sub(ln.get('params', {}).get('method', '') + '$', value, ln.get('line')) + ln['params']['method'] = value + return lines + last_line = last_line_dict['line'] prefix_start = last_line.find(last_line.split()[0]) suffix_start = last_line.rfind(last_line.split()[-1]) + len(last_line.split()[-1])