Network programming 厨师长:ifconfig资源不会永久禁用接口
我试图让chef禁用网络接口,使其在下次重新启动时不会出现 我的资源(debian 7.8上的kitchen)如下:Network programming 厨师长:ifconfig资源不会永久禁用接口,network-programming,chef-infra,Network Programming,Chef Infra,我试图让chef禁用网络接口,使其在下次重新启动时不会出现 我的资源(debian 7.8上的kitchen)如下: ifconfig "213.139.12.17" do device "eth1" onboot "no" action :disable end converge之后,界面确实会按预期下降,但/etc/network/interfaces处的文件似乎未被触动,重新启动时,界面会恢复,因为interfaces文件中的默认设置为“auto” 为什么chef不编辑/et
ifconfig "213.139.12.17" do
device "eth1"
onboot "no"
action :disable
end
converge之后,界面确实会按预期下降,但/etc/network/interfaces
处的文件似乎未被触动,重新启动时,界面会恢复,因为interfaces
文件中的默认设置为“auto”
为什么chef不编辑
/etc/network/interfaces
?难道不应该吗?是否有其他资源我想用于此目的?我认为只有ifconfig资源的:add
和:delete
操作写入配置文件(在某些平台上)
因此,如果您想保留接口,但不想启用它,我想您可以这样做:
ifconfig "213.139.12.17" do
device "eth1"
onboot "no"
action [:add, :disable]
end
这是一次黑客攻击,但我最终做的就是:
ifconfig "213.139.12.17" do
device "eth1"
onboot "no"
action :disable
notifies :run, "execute[remove-auto-eht1]", :immediately
end
execute "remove-auto-eth1" do
command "sed -i '/^auto eth1/s/^/#/' /etc/network/interfaces"
action :nothing
end
这是可行的,但我真的觉得当要求它禁用接口时,应该在
ifconfig
资源中处理这个问题。恐怕它不起作用。它创建了一个dir/etc/network/interfaces.d/
并添加了要在那里关闭的接口的conf,但是原始文件/etc/network/interfaces
仍然包含一行auto eth1
,这使得它在启动时启动。我将尝试添加一个execute
资源,并使用sed
命令将其删除。我会告诉你最新进展。(虽然我认为,ifconfig
资源的实现应该是固定的)@TomKlino Ok我希望:add操作将相关设置(不带auto关键字)写入/etc/network/interfaces。很抱歉给您指出了错误的方向查看poise file cookbook了解更结构化的方法