Just realized my code is slightly wrong for you since you wanted hex
values rather than alphanumeric string.
The first line should be:
<% range = [*'0'..'9',*'a'..'f'] -%>
On 11/25/2015 10:36 AM, Peter Kristolaitis wrote:
<% range = [*'0'..'9',*'A'..'Z',*'a'..'z'] -%>
<hid><%= Array.new(7){range.sample}.join + "-" +
Array.new(3){range.sample}.join %></hid>
The "<% range ... -%>" can be anywhere in your template as long as
it's before where you generate the random value. I usually put stuff
like that near the top of the template. If you're generating multiple
random values you only need to specify it once.
On 11/25/2015 09:48 AM, tobias.ko...@gmail.com wrote:
I want to create a random hex string in the format
|
041f798-a5f
|
/
/inclusive the dash in a XML file.
I have tried using a self written shell script which generates the
string with
|
<hid><%=exec('/var/somedir/somescript')%></hid>
|
in the template. That unfortunately didn't work.
I suspect I have to write a small embedded ruby template / code
snipplet to generate this structure but after some web search I still
have no idea how to do that in Embedded Ruby. Does somebody have a
short erb suggestion?
--
You received this message because you are subscribed to the Google
Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to puppet-users+unsubscr...@googlegroups.com
<mailto:puppet-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/17c87311-bf8c-4aba-98ed-af30f62e3aca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to puppet-users+unsubscr...@googlegroups.com
<mailto:puppet-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/5655D56A.3040803%40alter3d.ca
<https://groups.google.com/d/msgid/puppet-users/5655D56A.3040803%40alter3d.ca?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Puppet
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/5655D60C.9090403%40alter3d.ca.
For more options, visit https://groups.google.com/d/optout.