【问题标题】:puppet facter mac model傀儡因素mac模型
【发布时间】:2016-02-13 02:38:53
【问题描述】:

我正在创建一个木偶清单,并尝试使用基于 MAC 模型的内置事实变量。我正在使用本指南:https://docs.puppetlabs.com/facter/3.1/core_facts.html

我看到system_profiler 带有model_identifier 的选项,但我不确定正确的语法是什么。

这是我感到困惑的地方:

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

我在哪里/如何实际使用 model_identifier?我是 puppet 和 MAC 的新手,所以任何建议都会很棒!

【问题讨论】:

    标签: macos puppet


    【解决方案1】:

    我当前的facter v2.4版本不支持,但是无法成功安装最新的facter v3.1.4,所以无法测试代码。您的问题应该关闭。

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

    在你的mac上运行命令来证明。

    $ system_profiler SPHardwareDataType
    Hardware:
    
        Hardware Overview:
    
          Model Name: MacBook Pro
          Model Identifier: MacBookPro10,2
    

    相关代码在:

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

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

    【讨论】:

    • 非常感谢!我将如何使用 sp_machine_model? if $sp_machine_model == "MacBookPro10,2" { do the thing } else { don't do the thing }
    • 我觉得不错,或者$::sp_machine_model
    • 我试试看!谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-25
    相关资源
    最近更新 更多