ruby 傀儡/因素“无法检索事实 fqdn”:如何修复或规避?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7780322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 04:23:24  来源:igfitidea点击:

Puppet/Facter "Could not retrieve fact fqdn": How to fix or circumvent?

rubypuppetfacter

提问by Ryan Stewart

I'm learning about puppet and trying to experiment with it on a VM at home. I'm not using a puppet server yet, just running things locally. It works okay, but every time I run puppet apply ..., I get a delay of several seconds, after which it displays the message

我正在学习 puppet 并尝试在家里的 VM 上试验它。我还没有使用 puppet 服务器,只是在本地运行。它工作正常,但每次运行时puppet apply ...,我都会延迟几秒钟,之后它会显示消息

warning: Could not retrieve fact fqdn

I assume the message is linked to the delay, and I want to get rid of it (the delay--I can live with the message). Googling for a solution seems to indicate that it's somehow related to DNS lookups, but I can't really find anything else about it, which seems surprising. All I want is to be able to apply manifests in my vm quickly so I can experiment. How can I speed things up?

我假设该消息与延迟有关,我想摆脱它(延迟——我可以接受消息)。谷歌搜索解决方案似乎表明它与 DNS 查找有某种关系,但我真的找不到关于它的任何其他信息,这似乎令人惊讶。我想要的只是能够在我的 vm 中快速应用清单,以便我可以进行实验。我怎样才能加快速度?

Update:I don't see any extra info in the debug output, but it looks like this:

更新:我在调试输出中没有看到任何额外的信息,但它看起来像这样:

$ puppet apply -dv puppet-1.pp 
warning: Could not retrieve fact fqdn
debug: Failed to load library 'rubygems' for feature 'rubygems'
debug: Failed to load library 'selinux' for feature 'selinux'
debug: Puppet::Type::File::ProviderMicrosoft_windows: feature microsoft_windows is missing
...

Update:I added the "ruby" tag because puppet has so few followers. If this doesn't belong in ruby, or if you know a better tag for it, let me know.

更新:我添加了“ruby”标签,因为 puppet 的追随者太少了。如果这不属于 ruby​​,或者您知道更好的标签,请告诉我。

Update again:Having learned some more about puppet, I now understand that this message is coming from the component called "Facter" that sniffs out "facts" about the system that Puppet is running on. I found some configuration options and played around with "certname", "node_name"and "node_name_value", but I couldn't get the delay to go away. Does anyone know specifically how to either tell Facter to ignore the fqdn or how to make Facter able to find the fqdn on an Ubuntu 11.10 vm?

再次更新:在了解了有关 puppet 的更多信息后,我现在了解到此消息来自名为“Facter”的组件,该组件会嗅出有关运行 Puppet 的系统的“事实”。我找到了一些配置选项并尝试"certname""node_name""node_name_value",但我无法让延迟消失。有谁知道如何告诉 Facter 忽略 fqdn 或如何让 Facter 能够在 Ubuntu 11.10 虚拟机上找到 fqdn?

Progress:

进步:

$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.1

That's my router, which is running Dnsmasq via Tomato.

那是我的路由器,它通过 Tomato 运行 Dnsmasq。

$ dig -x 192.168.1.129 192.168.1.1

; <<>> DiG 9.7.3 <<>> -x 192.168.1.129 192.168.1.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21838
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;129.1.168.192.in-addr.arpa.    IN  PTR

;; ANSWER SECTION:
129.1.168.192.in-addr.arpa. 0   IN  PTR desk-vm-ubuntu-beta.

;; Query time: 14 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sun Oct 16 17:47:47 2011
;; MSG SIZE  rcvd: 77

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27462
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;192.168.1.1.           IN  A

;; ANSWER SECTION:
192.168.1.1.        0   IN  A   192.168.1.1

;; Query time: 11 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sun Oct 16 17:47:47 2011
;; MSG SIZE  rcvd: 45

straceled me to arp, which was blocking for 5 seconds and called twice for each facter:

strace带我到 arp,它阻塞了 5 秒,每个调用了两次facter

$ time arp -a
? (10.0.2.2) at 52:54:00:12:35:02 [ether] on eth0

real    0m5.127s
user    0m0.004s
sys     0m0.016s

I changed the VM from NAT networking to bridged, so that it now has an IP on the network, and arpreturns immediately now. (I'm no networking guru, so I have no idea why this worked, but it seemed a reasonable thing to try.) But facterstill takes about 4-5 seconds total to run and still reports "Could not retrieve fact fqdn". facter -dshows several occurrences of "value for domain is still nil", all the way to the end. I'm thinking something still isn't quite right.

我将虚拟机从 NAT 网络更改为桥接,以便它现在在网络上拥有一个 IP,并arp立即返回。(我不是网络专家,所以我不知道为什么会这样,但尝试一下似乎是合理的。)但facter仍然总共需要大约 4-5 秒才能运行并且仍然报告“无法检索事实 fqdn”。facter -d显示多次出现“域的值仍然为零”,一直到最后。我在想有些事情还是不太对劲。

采纳答案by freiheit

Since puppet uses the fqdn fact to determine which node it is running as, it may not be possible to run if it can't be determined. Given what you're describing, the simplest thing to debug is facter fqdninstead of your puppet command-line.

由于 puppet 使用 fqdn 事实来确定它作为哪个节点运行,如果无法确定它可能无法运行。鉴于您所描述的内容,调试最简单的方法是facter fqdn代替您的 puppet 命令行。

If the "several seconds" is very close to exactly 5 seconds, it's very likely that your DNS configuration is broken with a single bad DNS server listed. What's in /etc/resolv.conf? What happens if you run dig -x $HOSTIP $DNSSERVERIPwith the first nameserver listed in resolv.conf?

如果“几秒”非常接近 5 秒,则很可能是因为列出了一个错误的 DNS 服务器,因此您的 DNS 配置已损坏。/etc/resolv.conf 中有什么?如果您dig -x $HOSTIP $DNSSERVERIP使用 resolv.conf 中列出的第一个名称服务器运行会发生什么?

If you look in facter/fqdn.rbyou can see what exactly facter is trying to do to resolve the fqdn. In the version I have most handy it's using facter/hostname.rband facter/domainname.rbwhich call code from facter/util/resolution.rb.

如果您查看一下,facter/fqdn.rb您可以看到 facter 正在尝试做什么来解析 fqdn。在我使用的最方便的版本中facter/hostname.rbfacter/domainname.rb它从facter/util/resolution.rb.

Exactly what happens will depend on what version of facter you have, what OS, and possibly also what exactly you have installed. Calling /bin/hostname, uname(etc) and doing DNS lookups are all quite likely. You can always use strace -t facter fqdnto see what is taking the time (look for the gap in timestamps)

究竟会发生什么取决于您拥有什么版本的因子、什么操作系统,以及您可能究竟安装了什么。调用/bin/hostname, uname(etc) 和进行 DNS 查找都是很有可能的。您始终可以使用strace -t facter fqdn来查看花费时间的内容(查找时间戳中的差距)

From everything you've described, it does sound like the problem is that puppet/facter really wants to have a domain name and you don't have one, you just have a naked hostname.

从您描述的所有内容来看,问题确实是 puppet/facter 真的想要一个域名,而您没有域名,您只有一个裸主机名。

Adding domain example.comto /etc/resolv.conf should do the trick. Running hostname foo.example.comshould also do the trick (but will need to be re-applied). Permanent solutions depend on the exact OS setup.

添加domain example.com到 /etc/resolv.conf 应该可以解决问题。跑步hostname foo.example.com也应该可以解决问题(但需要重新应用)。永久解决方案取决于确切的操作系统设置。

回答by Teemu Leisti

I got the same error when running puppet on my home machine (Xubuntu). What worked for me was changing the second line of file /etc/hosts. The first two lines before the change:

在我的家用机器 (Xubuntu) 上运行 puppet 时,我遇到了同样的错误。对我有用的是更改 file 的第二行/etc/hosts。更改前的前两行:

127.0.0.1   localhost
127.0.1.1   box

And after the change:

更改后:

127.0.0.1   localhost
127.0.1.1   box.example.com box

Now, the command hostname -freturns box.example.cominstead of box, and puppet is happy.

现在,命令hostname -f返回box.example.com而不是box,并且 puppet 很高兴。

回答by shredding

Adding

添加

  config.vm.hostname = "vagrant.example.com"

to my Vagrantfilefixed it for me.

给我Vagrantfile修好了。

回答by jefflunt

FQDN stands for "fully qualified domain name". In a Windows domain (or other similar LDAP-based domain), for example, it would be the name of your network domain, such as "organization.internal" - the domain that your computers and servers are joined to, and the domain which contains your network groups and user accounts.

FQDN 代表“完全限定域名”。例如,在 Windows 域(或其他类似的基于 LDAP 的域)中,它将是您的网络域的名称,例如“organization.internal”——您的计算机和服务器加入的域,以及加入的域包含您的网络组和用户帐户。

So, it probably had trouble getting the fqdn for some authentication needed to perform the rest of the configuration steps, would be my guess.

因此,可能无法获得执行其余配置步骤所需的某些身份验证的 fqdn,这是我的猜测。

http://en.wikipedia.org/wiki/Fully_qualified_domain_name

http://en.wikipedia.org/wiki/Fully_qualified_domain_name

It's possible that you'll get a better answer on ServerFault, since system/configuration management also crosses over into their realm.

您可能会在 ServerFault 上得到更好的答案,因为系统/配置管理也跨越到它们的领域。

回答by Kit Ho

append this line into /etc/resolv.conf

将此行附加到 /etc/resolv.conf

domain abc.com

run facter fqdn again

再次运行因子 fqdn

Fqdn requires domain name , which maybe missing in your freshly installed ubu12

Fqdn 需要域名,您新安装的 ubu12 中可能缺少该域名

回答by ferventcoder

Another possible way to circumvent is to override the fact.

另一种可能的规避方法是覆盖事实。

http://www.puppetcookbook.com/posts/override-a-facter-fact.html

http://www.puppetcookbook.com/posts/override-a-facter-fact.html

FACTER_fqdn=box.example.com facter

On Windows this would be

在 Windows 上,这将是

SET FACTER_fqdn=box.example.com
facter fqdn