Ansible random UUID generation

As metioned by Xingxing Gao, there is to_uuid which can be used with a large enough number and the random filter to produce a random UUID. The larger the number the greater the randomness. eg:

{{ 99999999 | random | to_uuid }}

or

{{ 9999999999999999999999 | random | to_uuid }}

Generate a random UUID from a 20 char string with upper/lower case letters and digits:

{{ lookup('password', '/dev/null chars=ascii_letters,digits') | to_uuid }}

In ansible 1.9 there is a new filter : to_uuid , which given a string it will return an ansible domain specific UUID,you can find the usage in here https://docs.ansible.com/playbooks_filters.html#other-useful-filters

Tags:

Ansible