In case anybody else is looking to do the same thing, here is my BASH 
solution:

    - name: Sanitize Virtual Interface(s)
      shell: |
        file="/var/ftp/vm.cfg"
        total=$( grep ^vif "$file" | grep -o mac | wc -l )
        for i in `seq 1 $total`; do
          my_random=$(xxd -l 1 -p /dev/urandom )
          my_random2=$(xxd -l 1 -p /dev/urandom )
          sed -ri 
"s|mac=00:21:f6:((\w{2}(:)?){3})|mac=00:21:f6:aa:${my_random}:${my_random2}|${i}"
 
$file
        done


-- 
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/8a24e671-0f09-403b-92ca-0a118b7f4b11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to