John,

What problem are you actually trying to solve ?  Generating random numbers
especially around MAC certainly can get you in trouble.  Are you trying to
generate a Pool and apply something 1 time from that Pool ?

Explain the use case, and we could help a lot more.

-Thad

On Sat, Nov 10, 2018 at 3:07 AM Kai Stian Olstad <
[email protected]> 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
>
>
> --
> 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/118624768.r0sT80IGcL%40x1
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAChbWaNYXAYRRvBm-PXfMq2u5dC7y34gUNmL35s5V69xPN6Wtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to