从puppet中的文件访问密码以在exec中使用
我想在开源puppet中运行命令以激活Unity3D许可证,但我不想在git repo中使用序列号或密码:从puppet中的文件访问密码以在exec中使用,puppet,Puppet,我想在开源puppet中运行命令以激活Unity3D许可证,但我不想在git repo中使用序列号或密码: exec { 'license-unity': command => '/opt/Unity/Editor/Unity -batchmode -nographics -serial A1-ABCD-1234-ETC -username my.user@a.b.ca -password myPassword -quit' subscribe => Package['
exec { 'license-unity':
command => '/opt/Unity/Editor/Unity -batchmode -nographics -serial A1-ABCD-1234-ETC -username my.user@a.b.ca -password myPassword -quit'
subscribe => Package['UnityEditor'],
refreshonly => true,
}
如何从文件(在puppetserver或节点上)读取序列号和密码,并在命令中替换它
例如,如果我在puppet服务器上有一个名为
.secret
的文件,它由root和perms 400拥有。如何将内容读入一个变量,以便在puppet清单中使用 根据您喜欢的路线,有两种标准方法可实现此目的:
文件
功能。这适用于无主傀儡,或者文件托管在傀儡主控上
# using the module path instead of the absolute path would end up storing your secret in git, which is what you are trying to avoid
$password = file('/absolute/path/to/.secret')
exec { 'license-unity':
command => "/opt/Unity/Editor/Unity -batchmode -nographics -serial A1-ABCD-1234-ETC -username my.user@a.b.ca -password $password -quit"
subscribe => Package['UnityEditor'],
refreshonly => true,
}
文件:
推论:如果您需要对文件进行某种形式的解析,例如如果它不仅仅是一个包含密码的文本文件,那么您可以使用带有现代Ruby API的自定义函数。如果是这样,请告诉我# module/lib/facter/password.rb
Facter.add(:password) do
setcode do
File.read('/absolute/path/to/.secret')
end
end
# manifest.pp
exec { 'license-unity':
command => "/opt/Unity/Editor/Unity -batchmode -nographics -serial A1-ABCD-1234-ETC -username my.user@a.b.ca -password $password -quit"
subscribe => Package['UnityEditor'],
refreshonly => true,
}
文件:
推论:如果您需要对文件进行某种类型的解析,例如如果它不仅仅是一个包含密码的文本文件,那么您可以使用原生Ruby类和方法(即JSON.parse
或YAML.load_file
,如果文件采用这些格式)您所追求的方法的显著替代方法包括使用Puppet从机密管理软件(如Vault)检索,或使用加密/解密算法(如AES-256),将加密文件存储在SCM中,然后在目录编译期间对其进行解密。根据您喜欢的路径,有两种标准方法可以实现此目的:
文件
功能。这适用于无主傀儡,或者文件托管在傀儡主控上
# using the module path instead of the absolute path would end up storing your secret in git, which is what you are trying to avoid
$password = file('/absolute/path/to/.secret')
exec { 'license-unity':
command => "/opt/Unity/Editor/Unity -batchmode -nographics -serial A1-ABCD-1234-ETC -username my.user@a.b.ca -password $password -quit"
subscribe => Package['UnityEditor'],
refreshonly => true,
}
文件:
推论:如果您需要对文件进行某种形式的解析,例如如果它不仅仅是一个包含密码的文本文件,那么您可以使用带有现代Ruby API的自定义函数。如果是这样,请告诉我# module/lib/facter/password.rb
Facter.add(:password) do
setcode do
File.read('/absolute/path/to/.secret')
end
end
# manifest.pp
exec { 'license-unity':
command => "/opt/Unity/Editor/Unity -batchmode -nographics -serial A1-ABCD-1234-ETC -username my.user@a.b.ca -password $password -quit"
subscribe => Package['UnityEditor'],
refreshonly => true,
}
文件:
推论:如果您需要对文件进行某种类型的解析,例如如果它不仅仅是一个包含密码的文本文件,那么您可以使用原生Ruby类和方法(即JSON.parse
或YAML.load_file
,如果文件采用这些格式)您所追求的方法的显著替代方法包括使用Puppet从机密管理软件(如Vault)检索,或使用加密/解密算法(如AES-256),将加密文件存储在SCM中,然后在目录编译期间解密。什么版本的Puppet?最新的开放源码关于Hiera+eyaml?什么版本的Puppet?最新的开放源码关于Hiera+eyaml?值得一提的是,对于最近的Puppet,这两种方法最终都会在PuppetDB中记录密码。OP没有说任何关于这件事的话,所以也许没关系,但如果被这样的事情惊呆了,那就太糟糕了。@JohnBollinger说得很好,在这种情况下,如果这是一个问题,秘密管理可能是最好的选择。加密/解密函数也会将其存储在那里。值得一提的是,对于最近的Puppet,这两种方法最终都会在PuppetDB中记录密码。OP没有说任何关于这件事的话,所以也许没关系,但如果被这样的事情惊呆了,那就太糟糕了。@JohnBollinger说得很好,在这种情况下,如果这是一个问题,秘密管理可能是最好的选择。加密/解密函数也会将其存储在那里。