Support static network configuration even on already configured devices
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| | cloud-init |
High
|
Unassigned | ||
Bug Description
Some datasources (e.g. OpenNebula) support full static network configuration. It's done in local execution phase by pushing new interfaces configuration to *distro.
It would be good to first put interfaces down before writing new configuration.
| Changed in cloud-init: | |
| status: | New → Confirmed |
| importance: | Undecided → High |
| Scott Moser (smoser) wrote : | #1 |
| Vlastimil Holer (vlastimil-holer) wrote : | #2 |
Scott, don't take it bad, but I don't like the solution with ifquery. I believe it's Ubuntu/Debian specific and it would be fine to have a more platform independent solution. At least for those distros currently supported by cloud-init.
| Scott Moser (smoser) wrote : Re: [Bug 1225922] Re: Support static network configuration even on already configured devices | #3 |
On Mon, 16 Sep 2013, Vlastimil Holer wrote:
> Scott, don't take it bad, but I don't like the solution with ifquery. I
> believe it's Ubuntu/Debian specific and it would be fine to have a more
> platform independent solution. At least for those distros currently
> supported by cloud-init.
I'm not opposed to something at 'distro' level that would do the same
thing. I actually had thought that this datasource was currently
ubuntu/debian specific, but realize just now why using
'network-
That doesn't really change anything though, just where the code would be
put, and the fact that you'll have to do it for RH too.
Ie, you'll make the changes to bring down interfaces first in
cloudinit/distros
rather than in the datasource.
Scott
| Vlastimil Holer (vlastimil-holer) wrote : | #4 |
I have spent a little time and prepared this:
http://
(just as an working example, tested on Debian so far)
I don't know if you'll like...
| Josh Boon (josh-boon) wrote : | #5 |
The new interfaces.d in trusty makes this even more fun. I've been using local as datasource and user-data to configure and the introduction of interfaces.d completely breaks the old kinda working network config.
| Daryl Robbins (darylrobbins) wrote : | #6 |
Is there any work around for this issue? Thanks!
| Vlastimil Holer (vlastimil-holer) wrote : | #7 |
Yes, reboot instance after initial configuration. Put this into your
cloud-init configuration:
power_state:
mode: reboot
message: Initial configuration done by cloud-init, forcing reboot to
apply changes.
| Javi Fontan (jfontan) wrote : | #8 |
I managed to get it working setting all the interfaces down with this snippet:
bootcmd:
- ifdown -a
| Daryl Robbins (darylrobbins) wrote : | #9 |
Thanks for the quick responses! My issue is that I'm trying to run through additional steps after the network is configured: namely download and run chef-client. (on trusty Ubuntu 14.04)
Sometimes, the timings work out but most of the time, Ubuntu's network config and cloud-init step on each other's toes, causing the Chef omnibus install to fail.
chef:
install_type: omnibus
...
runcmd:
- ifdown eth0
- ifup eth0
- ifup eth1
- chef-client
Is there a potential way to get it working which plays nicely with running additional init steps? Thanks so much!
| Josh Boon (josh-boon) wrote : | #10 |
If you're using the cloud images in your own network I'd suggest just modifying the images and removing the eth0 config from /etc/interfaces.d Once I did that I had no issue applying static for my interfaces.
| Daryl Robbins (darylrobbins) wrote : | #11 |
Thanks, Josh. I removed the eth0 config file from the image, but am seeing a 'Route Info Failed'. Did you have to do anything else special to get it to work? I tried 'ifup -a' as both a bootcmd and runcmd but to no avail.
| Josh Boon (josh-boon) wrote : | #12 |
Here's what I have in meta-data:
#cloud-config
network-interfaces: |
auto eth0
iface eth0 inet static
address 192.168.100.55
network 192.168.100.0
netmask 255.255.255.0
broadcast 192.168.100.255
gateway 192.168.100.1
dns-nameservers $DNS
dns-search $DOMAIN
You should be able to drop the DNS if you're managing that elsewhere.
| Daryl Robbins (darylrobbins) wrote : | #13 |
Ugh, it just took me half an hour to notice that my only problem after removing eth0 from the image was that I forgot the auto. Thanks!
| Ken Schroeder (kschroed) wrote : | #14 |
Using runcmd helps with some scenarios but lot of things built into cloud-init already like package installs as well won't work if networking isn't online. I'm having similar challenges due to the start up ordering and having to build a lot of the functions cloud-init already servers in runcmd section after restarting networking once the static ip configs have been laid down.
| Kenneth Burger (burgerk) wrote : | #15 |
Following with the thought process of the proposal by smoser in #3, I have made the following change in cloudinit/
def apply_network(self, settings, bring_up=True):
# Write it out
dev_names = self._write_
# Now try to bring them up
if bring_up:
return self._bring_
return False
Then added these default implementations:
def _bring_
cmd = ['ifdown', device_name]
try:
(_out, err) = util.subp(cmd)
if len(err):
return True
except util.ProcessExe
return False
def _bring_
am_failed = 0
for d in device_names:
if not self._bring_
if am_failed == 0:
return True
return False
Since Ubuntu always returns --all for device_names, so implement in debian.py as:
def _bring_
use_all = False
for d in device_names:
if d == 'all':
if use_all:
return distros.
else:
return distros.
| Kenneth Burger (burgerk) wrote : | #16 |
Just noticed the duplicate Bug #1275098 ... The approach there looks very similar to what I did.
| Ahmed Rahal (arahal) wrote : | #17 |
As discussed with smoser on irc, putting that code in __init__.py is not acceptable.
As soon as I get the chance, I'll put it in the distro-specific code and re-propose. Am quite busy ATM :(
| Madhu Pavan (kmp) wrote : | #18 |
Hi arahal,
As one of the functionalities of __init__.py is to allows you to define methods at package level, which are common for all the distros in our case. Why don't we patch __init__.py as the issue is common for all the distros and patching it will solve the bug. Can you please share the details why smoser don't want the patch in __init__.py and rather have it in distro specific files? Thanks.
| Ahmed Rahal (arahal) wrote : | #19 |
Hi Madhu,
Here you have the full text of our chat on #cloud-init
http://
I still am planning to port https:/
Need to gather some sleep first ;)


Currently networking coming up happens independent of cloud-init. We could potentially make cloud-init local block networking from coming up, but I don't think thats something I'd want to take on for cloud-init 0.7.3 / Ubuntu 13.10.
I'm not really sure how much a hack this is, if at all. ['ifquery' , '--list', '--allow', 'auto'])
The solution I'd propose would be:
* use 'ifquery' to get the list of networking interfaces in the original
from cloudinit import util
(out, _err) = util.subp(
orig_list = out.splitlines()
* use ifquery to get the list of 'auto' interfaces in your new list: ['ifquery' , '--interfaces= /tmp/my. tmp.interfaces' ,
--list' , '--allow', 'auto'])
(out, _err) = util.subp(
new_list = out.splitlines()
* take down interfaces in orig_list and new_list subp([' ifdown' , iface]
for iface in [i for i in orig_list if i in new_list]:
util.
# have to ignore errors above in case the interface wasn't up.
* write/update /etc/network/ interfaces file
* bring all interfaces up: subp([' ifup', '-a'])
util.
I opened bug 1226067 (http:// pad.lv/ 1226067) to address an issue where
ifquery is busted in saucy, but that will get fixed.