mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-22 18:31:25 -07:00
[PR #7612/5adb7ab9 backport][stable-8] interfaces_file: filter by address_familiy when updating method (#7616)
interfaces_file: filter by address_familiy when updating method (#7612)
* When updating method, check address_family if provided.
* Also test modifying 'method' without address_family filter.
(cherry picked from commit 5adb7ab948
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
b7e68f5b2d
commit
e3eaeda81a
3 changed files with 62 additions and 0 deletions
|
@ -340,6 +340,8 @@ def addOptionAfterLine(option, value, iface, lines, last_line_dict, iface_option
|
|||
changed = False
|
||||
for ln in lines:
|
||||
if ln.get('line_type', '') == 'iface' and ln.get('iface', '') == iface and value != ln.get('params', {}).get('method', ''):
|
||||
if address_family is not None and ln.get('address_family') != address_family:
|
||||
continue
|
||||
changed = True
|
||||
ln['line'] = re.sub(ln.get('params', {}).get('method', '') + '$', value, ln.get('line'))
|
||||
ln['params']['method'] = value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue