On Wednesday, 7 November 2018 17:36:43 CET John Harmon wrote:
> 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.

This isn't easy with Ansible modules so that's probably why you haven't gotten 
an answer.
I probably wont give you one either.

To get different values you need multiple runs over the file.
When you run the fist one it will change all the lines, the same will happened 
on the second run but with different value but same value on each line.
To do this you would need a way to know which line you already changed and then 
avoid them.

The best thing in this circumstances is to let Ansible create the file with the 
template module.
Or use some external script like perl, awk, sed or python.


-- 
Kai Stian Olstad


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/118624768.r0sT80IGcL%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to