如何在木偶模板中获取代理的外部IP地址

how to get external ip address of agent in puppet template

在 puppet 中,核心事实 ipaddress 确实为我提供了代理的私有 IP 地址。

在erb-template中是否也有检索外部IP地址的快捷方式?

我想我可能要为它写一个小函数。

ipaddress 事实上只是 "does an ifconfig and returns the first non 127.0.0.0/8 subnetted IP it finds"。密码是 here. There are also facts available for the specific interfaces (ipaddress_eth0 etc). You may need to write a custom fact as you say, and it's very easy to do so. (Documentation here).

所有事实都可以在 ERB 模板中找到:

<%= @ipaddress %>

等等