summaryrefslogtreecommitdiff
path: root/lib/chef/provider/ifconfig/debian.rb
diff options
context:
space:
mode:
authorXabier de Zuazo <xabier@zuazo.org>2013-02-09 01:42:20 +0100
committerBryan McLellan <btm@opscode.com>2013-06-19 14:09:57 -0700
commit41638c81955157ff5aaad0ac0ad4a8de564038ed (patch)
tree155c63769e25428fb66b1ce4c879182b6139a7f9 /lib/chef/provider/ifconfig/debian.rb
parent0f4cfe59a789f0804fe406802af192702c8ac264 (diff)
downloadchef-41638c81955157ff5aaad0ac0ad4a8de564038ed.tar.gz
[CHEF-3029] first working version of Ifconfig::Debian provider
Diffstat (limited to 'lib/chef/provider/ifconfig/debian.rb')
-rw-r--r--lib/chef/provider/ifconfig/debian.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/chef/provider/ifconfig/debian.rb b/lib/chef/provider/ifconfig/debian.rb
index e3834bc78f..1a230e32bd 100644
--- a/lib/chef/provider/ifconfig/debian.rb
+++ b/lib/chef/provider/ifconfig/debian.rb
@@ -30,17 +30,18 @@ class Chef
content = %{
<% if @new_resource.device %>
<% if @new_resource.onboot == "yes" %>auto <%= @new_resource.device %><% end %>
-<% case @new_resource.onboot %>
-<% when "none" %>
+<% case @new_resource.bootproto
+ when "dhcp" %>
+iface <%= @new_resource.device %> inet dhcp
+<% when "bootp" %>
+iface <%= @new_resource.device %> inet bootp
+<% else %>
iface <%= @new_resource.device %> inet static
<% if @new_resource.target %>address <%= @new_resource.target %><% end %>
<% if @new_resource.mask %>netmask <%= @new_resource.mask %><% end %>
<% if @new_resource.network %>network <%= @new_resource.network %><% end %>
- <% if @new_resource.broadcast %>broadcast <%= @new_resource.broadcast %><% end %>
-<% when "dhcp" %>
-iface <%= @new_resource.device %> inet dhcp
-<% when "bootp" %>
-iface <%= @new_resource.device %> inet bootp
+ <% if @new_resource.bcast %>broadcast <%= @new_resource.bcast %><% end %>
+<% end %>
<% end %>
}
template = ::ERB.new(content)
@@ -67,7 +68,7 @@ iface <%= @new_resource.device %> inet bootp
private
def check_interfaces_config
- Dir.mkdir('/etc/network/interfaces.d') unless Dir.directory?('/etc/network/interfaces.d')
+ Dir.mkdir('/etc/network/interfaces.d') unless ::File.directory?('/etc/network/interfaces.d')
conf = Chef::Util::FileEdit.new('/etc/network/interfaces')
conf.insert_line_if_no_match('^\s*source\s+interfaces[.]d/[*]\s*(?:#.*)?$', 'source interfaces.d/*')
conf.write_file