How do I configure /etc/network/interfaces using chef?

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

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 mmisztal1980@gmail.comwrote:

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

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:

https://github.com/redguide/network_interfaces

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com) 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 mmisztal1980@gmail.com 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

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 eric.opscode@herot.com 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:

GitHub - sous-chefs/network_interfaces: Development repository for the network_interfaces cookbook

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com)
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 mmisztal1980@gmail.comwrote:

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

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 mmisztal1980@gmail.comwrote:

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 eric.opscode@herot.comwrote:

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:

GitHub - sous-chefs/network_interfaces: Development repository for the network_interfaces cookbook

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com)
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 mmisztal1980@gmail.comwrote:

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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l'UTC (Compiègne)

The best and easiest place to start is "how do you configure them without
Chef?"

You manipulate files under /etc.

With Chef, you'd start by identifying those files, and putting them under
Chef management.

In a recipe

template '/etc/network/interfaces' do
action :create
source 'interfaces.erb'
end

copy yourserver:/etc/network/interfaces into your cookbook under

templates/default/interfaces.erb

From, there you can start rendering data into this templates.

template '/etc/network/interfaces' do
action :create
source 'interfaces.erb'
variables(

)
end

On Wed, Mar 19, 2014 at 11:10 AM, Maciek Misztal mmisztal1980@gmail.comwrote:

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

er, accidentally sent that email before I was done writing it.

template '/etc/network/interfaces' do
action :create
source 'interfaces.erb'
variables(
eth0_ip => '1.2.3.4',
eth1_ip => '5.6.7.8',
eth2_ip => '9.10.11.12'
)
end

Then, in the interfaces.erb, dig it out with ERB templating:

Hello eth0's ip is <%= @eth0_ip %>
Hello eth1's ip is <%= @eth1_ip %>
Hello eth2's ip is <%= @eth2_ip %>

Iterate this way until you're done.

Consuming a random cookbook you found on the community site like that may
or may not work for you. That's going to require knowledge of Chef, the
cookbook, AND ubuntu network configuration.

If you have all three, great. If not, you may want to start more simply.

-s

On Thu, Mar 20, 2014 at 9:38 AM, Sean OMeara someara@opscode.com wrote:

The best and easiest place to start is "how do you configure them without
Chef?"

You manipulate files under /etc.

With Chef, you'd start by identifying those files, and putting them under
Chef management.

In a recipe

template '/etc/network/interfaces' do
action :create
source 'interfaces.erb'
end

copy yourserver:/etc/network/interfaces into your cookbook under

templates/default/interfaces.erb

From, there you can start rendering data into this templates.

template '/etc/network/interfaces' do
action :create
source 'interfaces.erb'
variables(

)
end

On Wed, Mar 19, 2014 at 11:10 AM, Maciek Misztal mmisztal1980@gmail.comwrote:

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

there already is such an issue - unattended :wink:

On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont
bvessemont@gmail.comwrote:

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 mmisztal1980@gmail.comwrote:

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 eric.opscode@herot.comwrote:

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:

GitHub - sous-chefs/network_interfaces: Development repository for the network_interfaces cookbook

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com)
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 mmisztal1980@gmail.comwrote:

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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l'UTC (Compiègne)

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 (mmisztal1980@gmail.com) wrote:

there already is such an issue - unattended :wink:

On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont bvessemont@gmail.com 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 mmisztal1980@gmail.com 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 eric.opscode@herot.com 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:

https://github.com/redguide/network_interfaces

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com) 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 mmisztal1980@gmail.com 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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l’UTC (Compiègne)

I would suggest that you don't use chef for this. Instead, put the
creation of interfaces into your build process, e.g. kickstart

On Thu, Mar 20, 2014 at 2:50 PM, Eric Herot eric.opscode@herot.com 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 (mmisztal1980@gmail.com)
wrote:

there already is such an issue - unattended :wink:

On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont <
bvessemont@gmail.com> 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 mmisztal1980@gmail.comwrote:

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 eric.opscode@herot.comwrote:

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:

GitHub - sous-chefs/network_interfaces: Development repository for the network_interfaces cookbook

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com)
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 <mmisztal1980@gmail.com

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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l'UTC (Compiègne)

I'd double vote this suggestion. There is a huge chicken and egg problem in
using a network based CM to manage the network interfaces.
We've been using such a system ( not chef ) for 10 years and it causes as
many problems as it solves.

If you need to automate the network config, then you need something like
Cobbler.

  • Booker C. Bense

On Thu, Mar 20, 2014 at 12:32 PM, Guy Matz guymatz@gmail.com wrote:

I would suggest that you don't use chef for this. Instead, put the
creation of interfaces into your build process, e.g. kickstart

On Thu, Mar 20, 2014 at 2:50 PM, Eric Herot eric.opscode@herot.comwrote:

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 (mmisztal1980@gmail.com)
wrote:

there already is such an issue - unattended :wink:

On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont <
bvessemont@gmail.com> 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 mmisztal1980@gmail.comwrote:

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 eric.opscode@herot.comwrote:

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:

GitHub - sous-chefs/network_interfaces: Development repository for the network_interfaces cookbook

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com)
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 <
mmisztal1980@gmail.com> 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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l'UTC (Compiègne)

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. :wink:

On Thu, Mar 20, 2014 at 7:50 PM, Eric Herot eric.opscode@herot.com 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 (mmisztal1980@gmail.com)
wrote:

there already is such an issue - unattended :wink:

On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont <
bvessemont@gmail.com> 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 mmisztal1980@gmail.comwrote:

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 eric.opscode@herot.comwrote:

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:

GitHub - sous-chefs/network_interfaces: Development repository for the network_interfaces cookbook

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com)
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 <mmisztal1980@gmail.com

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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l'UTC (Compiègne)

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:

…And one day will also be listed in the README. :wink:

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 (mmisztal1980@gmail.com) 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. :wink:

On Thu, Mar 20, 2014 at 7:50 PM, Eric Herot eric.opscode@herot.com 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 (mmisztal1980@gmail.com) wrote:

there already is such an issue - unattended :wink:

On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont bvessemont@gmail.com 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 mmisztal1980@gmail.com 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 eric.opscode@herot.com 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:

https://github.com/redguide/network_interfaces

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com) 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 mmisztal1980@gmail.com 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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l’UTC (Compiègne)

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: Eric Herot
Sent: ‎Friday‎, ‎March‎ ‎21‎, ‎2014 ‎4‎:‎28‎ ‎PM
To: chef@lists.opscode.com

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:

…And one day will also be listed in the README. :wink:

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 (mmisztal1980@gmail.com) 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. :wink:

On Thu, Mar 20, 2014 at 7:50 PM, Eric Herot eric.opscode@herot.com 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 (mmisztal1980@gmail.com) wrote:

there already is such an issue - unattended :wink:

On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont bvessemont@gmail.com 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 mmisztal1980@gmail.com 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 eric.opscode@herot.com 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 (kbarry-x@tunein.com) 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 mmisztal1980@gmail.com 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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l’UTC (Compiègne)

[cleaned up excessive Re’s]

Hi Maciej,

Sorry to take so long to respond. Mapping IPs to nodes is probably going to be the most cumbersome part of this. The best way I can think of to do this (others are encouraged to chime in with better suggestions because mine feels a bit clunky) is either to create a data bag with node name to IP mappings and then have the server look up its own entry in the data bag at bootstrap and assign the IP accordingly, or to use Chef to manage a DHCP server and then assign the IPs from there.

Here’s how you would do it with a data bag:

my_ips = data_bag_item(‘example_networking_bag’, ‘node_ips’)[node.name]

include_recipe ‘network_interfaces’

my_ips.each do |interface, if_conf|
network_interface interface do
target if_conf[‘ipaddr’]
mask if_conf[‘netmask’]
gateway if_conf[‘gateway’]
pre_up ‘sleep 2’ # in keeping with default behavior on Debian/Ubuntu.
end
end
…and the data bag item would look something like this:

{
“id”: “node_ips”,
“my-first-node-name”: {
“eth0”: {
“ipaddr”: “192.168.1.2”,
“netmask”: “255.255.255.0”,
“gateway”: “192.168.1.1”
},
“eth1”: {
“ipaddr”: “192.168.2.3”,
“netmask”: “255.255.255.0”,
“gateway”: “192.168.2.1”
},
},
“my-second-node-name”: {
“eth0”: {
“ipaddr”: “192.168.1.3”,
“netmask”: “255.255.255.0”,
“gateway”: “192.168.1.1”
},
“eth1”: {
“ipaddr”: “192.168.2.4”,
“netmask”: “255.255.255.0”,
“gateway”: “192.168.2.1”
}
}
}
Does that make sense?

Eric

On March 21, 2014 at 1:21:25 PM, mmisztal1980@gmail.com (mmisztal1980@gmail.com) wrote:

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: Eric Herot
Sent: ‎Friday‎, ‎March‎ ‎21‎, ‎2014 ‎4‎:‎28‎ ‎PM
To: chef@lists.opscode.com

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:

…And one day will also be listed in the README. :wink:

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 (mmisztal1980@gmail.com) 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. :wink:

On Thu, Mar 20, 2014 at 7:50 PM, Eric Herot eric.opscode@herot.com 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 (mmisztal1980@gmail.com) wrote:

there already is such an issue - unattended :wink:

On Thu, Mar 20, 2014 at 1:53 PM, Barthélemy Vessemont bvessemont@gmail.com 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 mmisztal1980@gmail.com 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 eric.opscode@herot.com 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:

https://github.com/redguide/network_interfaces

Eric

On March 19, 2014 at 12:09:24 PM, Kenneth Barry (kbarry-x@tunein.com) 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 mmisztal1980@gmail.com 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 - bvessemont@gmail.com
Ingénieur en informatique diplômé de l’UTC (Compiègne)