[chef] Using the ifconfig resource with DHCP?


Chronological Thread 
  • From: Kevin Keane Subscription < >
  • To: < >
  • Subject: [chef] Using the ifconfig resource with DHCP?
  • Date: Fri, 31 Jul 2015 11:17:18 -0700

Title: Using the ifconfig resource with DHCP?

I'm trying to use the ifconfig resource to set up an interface to use DHCP (this is on CentOS 6, chef client 12.4.1).

However, I can't figure out how to actually accomplish what I need.

Here is the resource I am using:

ifconfig "eth1" do
  device "eth1"
  onboot "yes"
  bootproto "dhcp"
end

Which expands to:

    ifconfig("eth1") do
      action [:add]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      target "eth1"
      device "eth1"
      onboot "yes"
      bootproto "dhcp"
      declared_type :ifconfig
      cookbook_name "main"
      recipe_name "default"
    end


I have two problems with it. First, this generates a configuration file named "ifcfg-" instead of "ifcfg-eth1" and second, it copies the resource name into the IP address - which obviously makes no sense for a DHCP interface. Unfortunately, the examples in the documentation are less than helpful, because they all use the IP address as the resource name.

In fact, the documentation actually is self-contradictory when it comes to DHCP. There is an example "Specify a boot protocol" that claims that this is what I'd need - and later the identical code in another example claims to generate a different configuration in the sample "Update a static IP address with a boot protocol"

How do I correctly use the ifconfig resource?

Here is the configuration file it generates:

# cat /etc/sysconfig/network-scripts/ifcfg-


>BOOTPROTO=dhcp
IPADDR=eth1




Kevin Keane

The NetTech

http://www.4nettech.com

Our values: Privacy, Liberty, Justice

See https://www.4nettech.com/corp/the-nettech-values.html





Archive powered by MHonArc 2.6.16.

§