Assume the following line:
vif = ['mac=00:21:f6:04:16:f3,bridge=101498d8ff',
'mac=00:21:f6:80:0b:d9,bridge=1017dc5841']
If I use lineinfile, replace, etc to do a regular expression match, can I
somehow apply the following to each instances (instead of just once for
both instances):
Action:
regexp: (vif\W+)?((?:, )?'mac=00:21:f6:)((\w{2}:?){3})(,bridge=\w+')(?:])?
line: \1\2AA:{{ 99 | random(start=10, step=1) }}:{{ 99 | random(start=10,
step=1) }}\5
Regexp Testing link:
https://regex101.com/r/JcgI7i/1
Desired (As shown above, keep first three octets of mac, change 4th to AA,
and the last two are random numbers between 10-99):
vif = ['mac=00:21:f6:AA:21:56,bridge=101498d8ff',
'mac=00:21:f6:AA:17:27,bridge=1017dc5841']
Actual (notice that they are both the same--which is what I don't want)
vif = ['mac=00:21:f6:AA:58:16,bridge=101498d8ff',
'mac=00:21:f6:AA:58:16,bridge=1017dc5841']
As I think about it I don't know of a way to do this within a single task.
Possibly in 2 tasks or more, but that number of vifs will vary from time to
time. It may be anywhere from 1-5 possibly.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/322f7bee-6fda-4dda-9c79-3f877edea07b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.