mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 20:31:27 -07:00
Search all assigned ipv6 addresses instead of just the first (#40533)
* Search all assigned ipv6 addresses instead of just the first * Add test for idempotency with multiple ipv6 addresses assigned
This commit is contained in:
parent
ed7d6d9c19
commit
e8d02a3a0f
2 changed files with 40 additions and 15 deletions
|
@ -148,9 +148,18 @@ def validate_param_values(module, obj, param=None):
|
|||
def parse_config_argument(configobj, name, arg=None):
|
||||
cfg = configobj['interface %s' % name]
|
||||
cfg = '\n'.join(cfg.children)
|
||||
match = re.search(r'%s (.+)$' % arg, cfg, re.M)
|
||||
if match:
|
||||
return match.group(1).strip()
|
||||
|
||||
values = []
|
||||
matches = re.finditer(r'%s (.+)$' % arg, cfg, re.M)
|
||||
for match in matches:
|
||||
match_str = match.group(1).strip()
|
||||
if arg == 'ipv6 address':
|
||||
values.append(match_str)
|
||||
else:
|
||||
values = match_str
|
||||
break
|
||||
|
||||
return values or None
|
||||
|
||||
|
||||
def search_obj_in_list(name, lst):
|
||||
|
@ -198,7 +207,7 @@ def map_obj_to_commands(updates, module):
|
|||
commands.append('ip address {}'.format(ipv4))
|
||||
|
||||
if ipv6:
|
||||
if obj_in_have is None or obj_in_have.get('ipv6') is None or ipv6.lower() != obj_in_have['ipv6'].lower():
|
||||
if obj_in_have is None or obj_in_have.get('ipv6') is None or ipv6.lower() not in [addr.lower() for addr in obj_in_have['ipv6']]:
|
||||
commands.append('ipv6 address {}'.format(ipv6))
|
||||
|
||||
if commands[-1] == interface:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue