Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用指定以太网适配器的 MAC 地址填充配置文件。
以太网适配器的名称(例如 eth1)是我定义的类型的参数。当我尝试通过 puppet 使用访问 macaddress 因子事实的 erb 模板填充配置文件时,这给了我 eth0 接口的 mac 地址,这是错误的(在这种情况下)。
如何在我定义的类型中创建一个变量,该变量采用因子 macaddress_ethernetinterface 的值,其中 ethernetinterface 由定义类型的参数定义?
有一整套macaddress事实,每个接口都有一个事实。
macaddress
notify { "eth1 has ${macaddress_eth1}": }
在您的模板中,您可以访问包含参数(例如$interface)的变量名称,例如
$interface
<%= scope.lookupvar("macaddress_#{ @interface }") %>
Facter 的未来版本将提供一个散列,允许查找每个接口的 MAC 地址。