mathematical operation

216 views
Skip to first unread message

Antidot SAS

unread,
Jun 20, 2012, 5:06:35 AM6/20/12
to puppet-users
HI everyone,




I am trying to use the ruby modulo function but without any success, here is the template:
--
$tt=regsubst($::hostname,'.*front(\d+).*','\1')
notice("$tt")
notice(inline_template("<% tt.to_i.modulo(60) %>"))
--
Here is the result:
notice: Scope(Class[main]): 04
notice: Scope(Class[main]):
notice: Finished catalog run in 0.22 seconds


Any idea?



Regards,
JM

Hendrik Jäger

unread,
Jun 20, 2012, 5:24:26 AM6/20/12
to puppet...@googlegroups.com
Hi,

- notice(inline_template("<% tt.to_i.modulo(60) %>"))
+ notice(inline_template("<%= tt.to_i.modulo(60) %>"))

Best regards

henk
signature.asc

Antidot SAS

unread,
Jun 20, 2012, 6:23:27 AM6/20/12
to puppet...@googlegroups.com
Thx, it helps :D

Ilya Dmitrichenko

unread,
Jun 24, 2012, 2:22:28 PM6/24/12
to puppet...@googlegroups.com


On Jun 20, 2012 10:06 AM, "Antidot SAS" <antid...@gmail.com> wrote:
>
> HI everyone,
>
>
>
>
> I am trying to use the ruby modulo function but without any success, here is the template:
> --
> $tt=regsubst($::hostname,'.*front(\d+).*','\1')
> notice("$tt")
> notice(inline_template("<% tt.to_i.modulo(60) %>"))

try `"<%= tt.to_i.modulo(60).to_s %>"`, well `to_s` is just for being explicit really and you can omit it, but what's important is the `<%=` instead of `%<`. See a Ruby template tutorial for more details :)

> --
> Here is the result:
> notice: Scope(Class[main]): 04
> notice: Scope(Class[main]):
> notice: Finished catalog run in 0.22 seconds
>
>
> Any idea?
>
>
>
> Regards,
> JM
>

> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Reply all
Reply to author
Forward
0 new messages