我正在跟随厨师之旅并学习如何解决厨师问题(https://learn.chef.io/modules/keep-your-cookbooks-up-to-date#/)。问题是我使用的每个发行版都获得了10.0.2.3 resolv.conf文件。
我试过这篇文章:https://serverfault.com/questions/453185/vagrant-virtualbox-dns-10-0-2-3-not-working
该解决方案仅适用于现有VM。在我的食谱中,我创建了一个模板resolv.conf.erb,并在我的default.rb的开头我把这段代码:
模板'/etc/resolv.conf'执行'resolv.conf.erb'模式'644'结束
但是,无论我如何尝试和配置它(default.rb是我的policyfile运行的第一件事),在部署我的resolv.conf模板之前,chef要求ubuntu从omnitruck.chef.io中获取wget。这是default.rb的全部内容:
#
# Cookbook:: base
# Recipe:: default
#
# Copyright:: 2019, The Authors, All Rights Reserved.
include_recipe 'hardening::default'
template '/etc/resolv.conf' do
source 'resolv.conf.erb'
mode '644'
end
file '/etc/motd' do
content node['base']['message']
end
我还需要配置什么才能让Chef在尝试wget之前部署resolv.conf?
chef通过在节点上下载并安装chef来执行其引导程序,然后仅使用运行列表中的配方执行chef-client。因此,在厨师启动其引导程序之前,您将需要使用您喜欢的dns解析器配置您的节点。
如果你使用vagrant
,你可以尝试vagrant-dns
或build your own vagrant basebox