在木偶中使用生成('…')的例子

我正在努力学习如何使用木偶,以及他们的快速入门指南 。

我想用generate生成一个时间戳:

$timestamp = generate('/bin/date') class helloworld::motd { file { '/etc/motd': owner => 'root', group => 'root', mode => '0644', content => "Production puppetmaster is in control. Last run: ${timestamp}\n", } } 

但由此产生的motd文件没有date/时间:

Production puppetmaster is in control. Last run:

我究竟做错了什么?

我根本不使用generate(),这是不惜一切代价避免的。

相反,看看stdlib Puppet模块,特别是下面的函数:

 strftime() time() 

示例:以下函数调用将导致YYYY-MM-DD HH:MM:SS格式的时间戳:

 $timestamp = stftime("%Y-%m-%d %k:%M:%S")