On Saturday, November 10, 2018 at 2:07:52 AM UTC-7, Kai Stian Olstad wrote:
>
> 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 
>
>
>
Thanks Kai.  I was thinking along those lines.  A template isn't applicable 
in this scenario.  I will just have to go with an outside script. 

-- 
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/b7140a69-5ce6-4c1e-8a25-7d0d1d3dc154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to