[chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: How do I configure /etc/network/interfaces using chef?


Chronological Thread 
  • From: < >
  • To: " " < >
  • Subject: [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: How do I configure /etc/network/interfaces using chef?
  • Date: Fri, 21 Mar 2014 17:19:36 +0000
  • Importance: Normal

Hi Eric,

This seems to be the direction I want to follow, I now understand how are you achieving certain things, however I still don’t see how is this applied to multiple nodes? Let’s assume that each machine needs to have static IPs assigned to it’s NICs, how would you achieve that?

Best regards,
Maciej

Sent from Windows Mail

From:  " target="_parent">Eric Herot
Sent: ‎Friday‎, ‎March‎ ‎21‎, ‎2014 ‎4‎:‎28‎ ‎PM
To:  " target="_parent">

Hi Maciek,

So there are a lot of possible ways to do this, but I suppose the first thing I’d need to know is whether these interfaces need to be set up with static addresses or dynamic ones, and whether all 4 interfaces in the example would need to have different setups.

The simplest thing to do would be to just define a both interfaces using DHCP in a single wrapper cookbook and then place that wrapper cookbook in the run list of both nodes.  That might look something like this:

include_recipe 'network_interfaces'

%w(eth0 eth1).each do |alias|
  network_interface alias do
    bootproto 'dhcp'
  end
end

Obviously if you want to specify static IPs per node that’s going to require some finagling.  The right way to do it will be determined by exactly how you want to allocate IPs.  If you can give me some feedback on this I might be able to give you some suggestions.

Almost any property that can be specified in the /etc/network/interfaces config file will be listed in the resource definition:

https://github.com/redguide/network_interfaces/blob/v1.0.0/resources/default.rb

…And one day will also be listed in the README. ;-)

Also, anything that is not included in that resources file can be added by setting the “custom” property with a hash.

E.g.

network_interface 'eth0' do
  target '192.168.0.1'
  custom(
    'myproperty1' => 'myvalue1',
    'myproperty2' => 'myvalue2'
  )
end

Please let me know if any of that isn’t clear or if I left out something you need.

-- 
Eric

On March 20, 2014 at 6:05:18 PM, Maciek Misztal ( " target="_parent"> ) wrote:

Hi Eric,


If you would be so kind and elaborate :

How would you configure multiple nodes with multiple interfaces using this cookbook? Can you give me a simple 2 nodes with 2 interfaces each example?

Please assume that I know little of chef and I'm trying to understand how to "model" the whole thing - while I have some experience with ruby, not much but sufficient for rake/chef etc. ;)


On Thu, Mar 20, 2014 at 7:50 PM, Eric Herot < " target="_parent"> > wrote:
Hi Maciek,

Definitely agree about the docs.  I have a Trello card open right now to deal with that in the next few weeks.

Barthélemy’s example will probably serve your purposes but in case it doesn’t, please let me know if there are any specific questions I can answer in the mean time.  I do not own the cookbook but I am a contributor to it.
-- 
Eric

On March 20, 2014 at 12:18:14 PM, Maciek Misztal ( " target="_parent"> ) wrote:

there already is such an issue - unattended ;)


On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont < " target="_parent"> > wrote:
Ohai !

I'm working regularly with this cookbook's author. Don't hesitate to create a github issue asking for some doc if you feel the need to.

Actually I'm using this very simple resource to manage my server's eth0 :

network_interfaces 'eth0' do
  target '10.10.16.203'
  mask '255.255.128.0'
  gateway '10.10.1.253'
end


there is other options you can use, you'd better look at lwrp ressource file to understand how it can work, and what can be changed :
attribute :device, kind_of: String, name_attribute: true
attribute :bridge, kind_of: [TrueClass, FalseClass, Array]
attribute :bridge_stp, kind_of: [TrueClass, FalseClass]
attribute :bond, kind_of: [TrueClass, FalseClass, Array]
attribute :bond_mode, kind_of: String
attribute :vlan_dev, kind_of: String
attribute :onboot, kind_of: [TrueClass, FalseClass], default: true
attribute :bootproto, kind_of: String
attribute :target, kind_of: String
attribute :gateway, kind_of: String
attribute :metric, kind_of: Integer
attribute :mtu, kind_of: Integer
attribute :mask, kind_of: String
attribute :network, kind_of: String
attribute :broadcast, kind_of: String
attribute :pre_up, kind_of: String
attribute :up, kind_of: String
attribute :post_up, kind_of: String
attribute :pre_down, kind_of: String
attribute :down, kind_of: String
attribute :post_down, kind_of: String
attribute :custom, kind_of: Hash




On Wed, Mar 19, 2014 at 7:04 PM, Maciek Misztal < " target="_parent"> > wrote:
Are there some usage examples? This cookbook's documentation is severely lacking - I'm not proficient with Chef yet, so I'm having a hard time understanding how to use it.

cheers,
Maciej


On Wed, Mar 19, 2014 at 5:25 PM, Eric Herot < " target="_parent"> > wrote:
Not sure if this is useful for your particular case but if what you’re trying to do is set up some existing physical NICs (or virtual NICs if you’re in a cloud computing environment) there is a cookbook for that:

-- 
Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry ( " target="_parent"> ) wrote:

I'm going to take an initial whack at this, and say I "think" its going to be something like

node[network][interfaces].each do |nic|
[whatever you want to do here]

Youll probably wanna add a bit of logic just after that first line to help ignore it is the nic is the lo nic.

Other will certainly improve on this.


On Wed, Mar 19, 2014 at 8:10 AM, Maciek Misztal < " target="_parent"> > wrote:
I'm looking for a way to configure N (N=3) ubuntu nodes with 2 network interfaces each - since I'm a complete newb, what is the proper way to do it?

Regards,
Maciej





--
Barthélemy Vessemont - " target="_parent">
Ingénieur en informatique diplômé de l'UTC (Compiègne)





Archive powered by MHonArc 2.6.16.

§