gpt4 book ai didi

ruby-on-rails - 在运行 Recipe 的其余部分之前使用 Chef 设置 DNS?

转载 作者:太空宇宙 更新时间:2023-11-03 17:04:34 25 4
gpt4 key购买 nike

我正在跟随 Chef 之旅并学习如何对 Chef 进行故障排除 (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

不过,该解决方案仅适用于现有虚拟机。在我的 Recipe 中,我创建了一个模板 resolv.conf.erb 并在我的 default.rb 的开头放置了这段代码:

模板'/etc/resolv.conf'做 来源'resolv.conf.erb' 模式“644”结束

但是,无论我如何尝试和配置它(default.rb 是我的策略文件运行的第一件事), Chef 都会要求 ubuntu 在部署我的 resolv.conf 模板之前从 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 来执行其 Bootstrap ,然后才使用运行列表中的 Recipe 执行 chef-client。因此,在 Chef 启动其 Bootstrap 之前,您需要使用您最喜欢的 dns 解析器配置您的节点。

如果您使用 vagrant , 你可以试试vagrant-dnsbuild your own vagrant basebox

关于ruby-on-rails - 在运行 Recipe 的其余部分之前使用 Chef 设置 DNS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55190986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com