本文介绍了人偶节点主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用人偶来配置服务器.我想在* .erb模板中打印当前的计算机(节点)名称.有 hostname 变量,但这包含puppetmaster主机名.是否有关于此主题的良好参考/列表?

I'm using puppet to configure servers. I want to print current machine (node) name in *.erb template. There is hostname variable, but this holds puppetmaster hostname. Is there any good reference/list regarding to this topic?

推荐答案

好像我错过了某个地方.我可以简单地通过调用* .erb模板中的以下代码来获取(打印)节点主机名:

Seems like I have miss-looked somewhere. I can get(print) node-hostname simply by invoking following code in *.erb template:

<%= @hostname %>

从Puppet 3开始,使用局部变量(即已弃用hostname; Puppet 4将完全删除对它们的支持.建议的方法是使用实​​例变量(以@前缀).因此,在这种情况下, @hostname.来源

As of Puppet 3, using local variables (i.e. hostname is deprecated; Puppet 4 will remove support for them entirely. The recommended way is to use instance variables (prefixed with @. So in this case, @hostname. Source

这篇关于人偶节点主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 08:22