简体   繁体   中英

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. I'm using this guide: 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.

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? I'm new to puppet and MAC so any advice would be great!

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. 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.

$ 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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