简体   繁体   English

人偶事实Mac模型

[英]puppet facter mac model

I'm creating a puppet manifest and I'm trying to use a built in facter variable based on the MAC model. 我正在创建一个人偶清单,并试图使用基于MAC模型的内置变量。 I'm using this guide: https://docs.puppetlabs.com/facter/3.1/core_facts.html 我正在使用此指南: https : //docs.puppetlabs.com/facter/3.1/core_facts.html

I saw system_profiler with an option for model_identifier but I'm not sure what the correct syntax is. 我看到system_profiler带有model_identifier选项,但是我不确定正确的语法是什么。

Here is where I'm confused: 这是我很困惑的地方:

class::something::mac
if $<% system_profiler %> eq "macpro"; then
do the thing
else
don't do the thing

Where/how do I actually use model_identifier? 我实际在哪里/如何使用model_identifier? I'm new to puppet and MAC so any advice would be great! 我是puppet和MAC的新手,所以任何建议都很棒!

My current facter version v2.4 doesn't support it, but I can't successfully install latest facter v3.1.4, so can't test the code. 我当前的工厂版本v2.4不支持它,但是我无法成功安装最新的工厂版本v3.1.4,因此无法测试代码。 It should be closed for your question. 您的问题应该关闭。

if $::system_profiler::model_identifier == "MacBookPro10,2" {
   do the thing
}
else {
   don't do the thing
}

Run the command on your mac to prove it. 在Mac上运行命令进行验证。

$ system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro10,2

Related codes at: 相关代码:

+            { "Model Identifier",       [](data& d) -> string& { return d.model_identifier; } },

https://github.com/puppetlabs/facter/commit/4283cfe23b56f22b03fbc863a3eb1498d2bcbea9#diff-c8b70e57e1ae5727ed062f26d5a9fa30R25 https://github.com/puppetlabs/facter/commit/4283cfe23b56f22b03fbc863a3eb1498d2bcbea9#diff-c8b70e57e1ae5727ed062f26d5a9fa30R25

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM