![](/img/trans.png)
[英]Puppet is not able to create files in C:\windows\system32 folder
[英]How to create folder name with custom facts using puppet in Windows?
我写了一个自定义事实来在Windows中创建当前日期和时间,当我通知它时会返回当前日期和时间。
例如:
notify{"test time":
message=>"$::windows_time",
}
上面的代码的输出是'05 -04-2016-194645'
但是,当我尝试使用自定义事实创建文件夹时,无法创建带有时间戳的文件夹。 我的代码如下。
exec{"current date time folder":
cwd=>"${prodequ_backup_loc}",
command=>'C:\Windows\System32\cmd.exe /c "md $::windows_time"',
}
上面的代码用“ $ {windows_time}”创建了一个文件夹名称。
我创建日期和时间戳的事实如下:
require 'facter'
#
##Default for non-Linux nodes
Facter.add(:windows_time) do
setcode do
Facter::Util::Resolution.exec('C:\\Windows\\System32\\cmd.exe /c "C:\\time1.bat"')
end
end
#For Linux Nodes
Facter.add(:windows_time) do
confine :kernel => :linux
setcode do
nil
end
end
任何帮助深表感谢。
参考
码:
file {"c:\\full\\path\\to\\${::windows_time}":
ensure => directory,
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.