diff --git a/changelogs/fragments/6131-fix-interfaces_file-for-no-leading-spaces.yml b/changelogs/fragments/6131-fix-interfaces_file-for-no-leading-spaces.yml new file mode 100644 index 0000000000..c975d4e624 --- /dev/null +++ b/changelogs/fragments/6131-fix-interfaces_file-for-no-leading-spaces.yml @@ -0,0 +1,2 @@ +bugfixes: + - interfaces_file - fix reading options in lines not starting with a space (https://github.com/ansible-collections/community.general/issues/6120). diff --git a/plugins/modules/interfaces_file.py b/plugins/modules/interfaces_file.py index 8e643fb797..f19c019f4e 100644 --- a/plugins/modules/interfaces_file.py +++ b/plugins/modules/interfaces_file.py @@ -156,20 +156,22 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.common.text.converters import to_bytes -def line_dict(line): +def lineDict(line): return {'line': line, 'line_type': 'unknown'} -def make_option_dict(line, iface, option, value, address_family): +def optionDict(line, iface, option, value, address_family): return {'line': line, 'iface': iface, 'option': option, 'value': value, 'line_type': 'option', 'address_family': address_family} -def get_option_value(line): - patt = re.compile(r'^\s+(?P