[one-users] Using CloudInit for contextualization

Javier Fontan jfontan at opennebula.org
Thu Feb 13 05:44:58 PST 2014


I've been playing a bit more with cloud-init and ubuntu. Unfortunately
I could not make it work in the saucy images. They come with
cloud-init 0.7.3 and they should be compatible but I was not able to
make the user_data work.

With development images (trusty) I've managed to make it work but
still has some problems with the network. To make it configure the
network correctly it needs to be down so the network configuration
part makes its work. Here is the context I've been using:

--8<------
CONTEXT=[
  NETWORK="YES",
  SSH_PUBLIC_KEY="$USER[SSH_PUBLIC_KEY]",
  USER_DATA="#cloud-config
bootcmd:
  - ifdown -a
runcmd:
  - curl http://10.0.1.1:8999/I_am_alive
write_files:
-   encoding: b64
    content: RG9lcyBpdCB3b3JrPwo=
    owner: root:root
    path: /etc/test_file
    permissions: '0644'
packages:
  - ruby2.0" ]
------>8--

The bootcmd part brings down the network so it is configured (and
brought up) by network contextualization. That is the important part.
The other sections are just tests:

* runcmd tries to connect to another machine, just to check that
networking is ready when user data scripts are being executed
* write_files is there in case network does not work to check that the
user data script executed.
* packages installs the ruby interpreter, again to check networking
and user data.

trusty image comes with cloud-init 0.7.5 (is not available for saucy).
I believe that upgrading the cloud-init package will make the saucy
image work.

It takes about 2.5 minutes to boot the first time as dhcp is trying to
get an IP and I don't have a dhcp server.

On Thu, Feb 6, 2014 at 6:28 PM, Javier Fontan <jfontan at opennebula.org> wrote:
> If I remember correctly the file is /var/lib/cloud/instance/user-data.
> I've been also checking the log files but there's nothing interesting
> to me.
>
> In case you want to run cloud-init manually you can use:
>
> # cloud-init -d init --local
>
>
> On Thu, Feb 6, 2014 at 5:26 PM, Wilma Hermann <wilma.hermann at gmail.com> wrote:
>> Good to hear that the problem is reproducible. I was really about to doubt
>> myself. Can't be so hard to get a config file right ;)
>>
>> Where is that user data file stored in the VM? Maybe you could tell me,
>> where you would continue to debug. Maybe I can help you out.
>>
>> Greetings
>> Wilma
>>
>>
>> 2014-02-06 Javier Fontan <jfontan at opennebula.org>:
>>
>>> I've been trying the image and I could not make the user data work.
>>> Cloud-init is able to get networking options and configures the
>>> network but it doesn't restart it so the changes make any effect. It
>>> is also able to get the user data and writes it to the user data file
>>> used later for configuration but it does nothing with it. It could be
>>> a problem with the cloud-init configuration in that machine.
>>>
>>> I'll do more debugging as soon as I get some time.
>>>
>>> On Tue, Feb 4, 2014 at 1:19 PM, Javier Fontan <jfontan at opennebula.org>
>>> wrote:
>>> > I'll try to test that image and will let you know what I can find.
>>> >
>>> > On Tue, Feb 4, 2014 at 1:18 PM, Wilma Hermann <wilma.hermann at gmail.com>
>>> > wrote:
>>> >> No, I never touched that file. It's current setting is
>>> >>
>>> >> DISK     = [ driver = "raw" , cache = "none"]
>>> >>
>>> >> I also tried converting the Ubuntu Image to qcow and raw using qemu-img
>>> >> to
>>> >> make sure it is no problem with the image format. That also didn't
>>> >> change
>>> >> anything.
>>> >>
>>> >>
>>> >> 2014-02-04 Javier Fontan <jfontan at opennebula.org>:
>>> >>>
>>> >>> It's a long shot but do you have the default image set to qcow2? In
>>> >>> '/etc/one/vmm_exec/vmm_exec_kvm.conf':
>>> >>>
>>> >>> DISK     = [ driver = "qcow2" ]
>>> >>>
>>> >>> If this is the case change it to raw, restart oned and try again. The
>>> >>> image already has the driver set to qcow2 so it should work.
>>> >>>
>>> >>> On Tue, Feb 4, 2014 at 11:48 AM, Wilma Hermann
>>> >>> <wilma.hermann at gmail.com>
>>> >>> wrote:
>>> >>> > I also tried it with the current Alpha 2 of Ubuntu 14.04 which
>>> >>> > includes
>>> >>> > cloud-init 0.7.5, but it does not work either. You can find the
>>> >>> > output
>>> >>> > of
>>> >>> > onevm and oneimage attached.
>>> >>> >
>>> >>> > Thanks in advance
>>> >>> > Wilma
>>> >>> >
>>> >>> > 2014-02-04 Javier Fontan <jfontan at opennebula.org>:
>>> >>> >
>>> >>> >> It should be working. Can you send us the output of "onevm show -x
>>> >>> >> <vmid>" of one of those machines?
>>> >>> >>
>>> >>> >> On Mon, Feb 3, 2014 at 6:17 PM, Wilma Hermann
>>> >>> >> <wilma.hermann at gmail.com>
>>> >>> >> wrote:
>>> >>> >> > Hi,
>>> >>> >> >
>>> >>> >> > I'm using the release image from yesterday (02-Feb-2014 03:39)
>>> >>> >> > [1].
>>> >>> >> > And
>>> >>> >> > the
>>> >>> >> > machine uses cloud-init 0.7.3:
>>> >>> >> >
>>> >>> >> > # virt-cat one-42 /var/log/cloud-init.log | grep running
>>> >>> >> > 2014-02-03 15:18:56,873 - util.py[DEBUG]: Cloud-init v. 0.7.3
>>> >>> >> > running
>>> >>> >> > 'init-local' at Mon, 03 Feb 2014 15:18:56 +0000. Up 4.48 seconds.
>>> >>> >> >
>>> >>> >> > [1]: http://cloud-images.ubuntu.com/releases/13.10/release/
>>> >>> >> >
>>> >>> >> > Thanks in advance
>>> >>> >> > Wilma
>>> >>> >> >
>>> >>> >> > 2014-02-03 Javier Fontan <jfontan at opennebula.org>:
>>> >>> >> >
>>> >>> >> >> Are you using a recent version of those images? OpenNebula
>>> >>> >> >> support
>>> >>> >> >> was
>>> >>> >> >> added in cloud-init 0.7.3 and the current images come with that
>>> >>> >> >> version. User data can be specified with USER_DATA or USERDATA
>>> >>> >> >> parameters so your configuration seems to be OK.
>>> >>> >> >>
>>> >>> >> >> On Mon, Feb 3, 2014 at 5:54 PM, Wilma Hermann
>>> >>> >> >> <wilma.hermann at gmail.com>
>>> >>> >> >> wrote:
>>> >>> >> >> > Hi,
>>> >>> >> >> >
>>> >>> >> >> > Well, the core of the problem sounds logical to me.
>>> >>> >> >> > Nevertheless,
>>> >>> >> >> > I
>>> >>> >> >> > have
>>> >>> >> >> > to
>>> >>> >> >> > wait 2 minutes for the network initialization to time-out
>>> >>> >> >> > until I
>>> >>> >> >> > can
>>> >>> >> >> > reboot
>>> >>> >> >> > the machine using the CtrlAltDel-Button in VNC... That's not
>>> >>> >> >> > comfortable,
>>> >>> >> >> > but bearable.
>>> >>> >> >> >
>>> >>> >> >> > However, I cannot get that USER_DATA variable to work.
>>> >>> >> >> > Whatever I
>>> >>> >> >> > enter
>>> >>> >> >> > there, it is obviously ignored. I tried it with the exact code
>>> >>> >> >> > from
>>> >>> >> >> > the
>>> >>> >> >> > documentation you mentioned, but also with something like
>>> >>> >> >> >
>>> >>> >> >> > CONTEXT=[NETWORK="YES",SSH_PUBLIC_KEY="$USER[SSH_PUBLIC_KEY]",
>>> >>> >> >> >   USER_DATA="#cloud-config
>>> >>> >> >> > bootcmd:
>>> >>> >> >> >  - echo HelloWorld > /etc/issue
>>> >>> >> >> > " ]
>>> >>> >> >> >
>>> >>> >> >> > just to get a visual feedback that the USER_DATA is being used
>>> >>> >> >> > by
>>> >>> >> >> > cloud-init. None of it worked out.
>>> >>> >> >> >
>>> >>> >> >> > Is there a special trick with USER_DATA?
>>> >>> >> >> >
>>> >>> >> >> > Just in case that's important: I'm using OpenNebula 4.4 with
>>> >>> >> >> > libvirt/KVM.
>>> >>> >> >> >
>>> >>> >> >> > Thanks in advance
>>> >>> >> >> > Wilma
>>> >>> >> >> >
>>> >>> >> >> > 2014-01-30 Javier Fontan <jfontan at opennebula.org>:
>>> >>> >> >> >
>>> >>> >> >> >> Unfortunately the current version of cloud-init does not load
>>> >>> >> >> >> new
>>> >>> >> >> >> network parameters after they are configured in some
>>> >>> >> >> >> distributions.
>>> >>> >> >> >> There is a ticket to track that problem [1]
>>> >>> >> >> >>
>>> >>> >> >> >> The documentation gives some ideas on how to overcome this
>>> >>> >> >> >> [2]:
>>> >>> >> >> >>
>>> >>> >> >> >> --8<------
>>> >>> >> >> >> The current version of cloud-init configures the network
>>> >>> >> >> >> before
>>> >>> >> >> >> running cloud-init configuration. This makes the network
>>> >>> >> >> >> configuration
>>> >>> >> >> >> not reliable. Until a new version that fixes this is released
>>> >>> >> >> >> you
>>> >>> >> >> >> can
>>> >>> >> >> >> add OpenNebula context packages or this user data to reboot
>>> >>> >> >> >> the
>>> >>> >> >> >> machine so the network is properly configured.
>>> >>> >> >> >> ------>8--
>>> >>> >> >> >>
>>> >>> >> >> >> [1] https://bugs.launchpad.net/cloud-init/+bug/1225922
>>> >>> >> >> >> [2]
>>> >>> >> >> >>
>>> >>> >> >> >>
>>> >>> >> >> >>
>>> >>> >> >> >>
>>> >>> >> >> >> http://docs.opennebula.org/stable/user/virtual_machine_setup/cloud-init.html
>>> >>> >> >> >>
>>> >>> >> >> >> On Tue, Jan 28, 2014 at 1:56 PM, Wilma Hermann
>>> >>> >> >> >> <wilma.hermann at gmail.com>
>>> >>> >> >> >> wrote:
>>> >>> >> >> >> > Hi,
>>> >>> >> >> >> >
>>> >>> >> >> >> > I'm trying to get a Ubuntu 13.10 guest to work, which uses
>>> >>> >> >> >> > a
>>> >>> >> >> >> > official
>>> >>> >> >> >> > Cloud-image (http://cloud-images.ubuntu.com/saucy/) as
>>> >>> >> >> >> > disk.
>>> >>> >> >> >> > However,
>>> >>> >> >> >> > the VM
>>> >>> >> >> >> > is not integrating into the virtual network. I've double
>>> >>> >> >> >> > checked
>>> >>> >> >> >> > the
>>> >>> >> >> >> > virtual
>>> >>> >> >> >> > network settings with CentOS-VMs, the network works
>>> >>> >> >> >> > correctly.
>>> >>> >> >> >> >
>>> >>> >> >> >> > I've found out that CloudInit writes a correct
>>> >>> >> >> >> > /etc/network/interfaces
>>> >>> >> >> >> > file
>>> >>> >> >> >> > with a static address, however, the machine somehow ignores
>>> >>> >> >> >> > this
>>> >>> >> >> >> > file
>>> >>> >> >> >> > and
>>> >>> >> >> >> > keeps sending DHCP requests without getting an answer
>>> >>> >> >> >> > (which is
>>> >>> >> >> >> > intended
>>> >>> >> >> >> > since we don't use DHCP in the VM's network).
>>> >>> >> >> >> >
>>> >>> >> >> >> > # virt-cat one-42 /etc/network/interfaces
>>> >>> >> >> >> > auto lo
>>> >>> >> >> >> > iface lo inet loopback
>>> >>> >> >> >> >
>>> >>> >> >> >> > auto eth0
>>> >>> >> >> >> > iface eth0 inet static
>>> >>> >> >> >> >   address 192.168.129.4
>>> >>> >> >> >> >   network 192.168.128.0
>>> >>> >> >> >> >   netmask 255.255.254.0
>>> >>> >> >> >> >   gateway 192.168.128.1
>>> >>> >> >> >> >
>>> >>> >> >> >> > # virt-cat one-42 /var/log/syslog | tail -6
>>> >>> >> >> >> > Jan 28 12:42:44 ubuntu dhclient: DHCPDISCOVER on eth0 to
>>> >>> >> >> >> > 255.255.255.255
>>> >>> >> >> >> > port 67 interval 21 (xid=0x1080a577)
>>> >>> >> >> >> > Jan 28 12:43:05 ubuntu dhclient: DHCPDISCOVER on eth0 to
>>> >>> >> >> >> > 255.255.255.255
>>> >>> >> >> >> > port 67 interval 13 (xid=0x1080a577)
>>> >>> >> >> >> > Jan 28 12:43:18 ubuntu dhclient: DHCPDISCOVER on eth0 to
>>> >>> >> >> >> > 255.255.255.255
>>> >>> >> >> >> > port 67 interval 20 (xid=0x1080a577)
>>> >>> >> >> >> > Jan 28 12:43:38 ubuntu dhclient: DHCPDISCOVER on eth0 to
>>> >>> >> >> >> > 255.255.255.255
>>> >>> >> >> >> > port 67 interval 1 (xid=0x1080a577)
>>> >>> >> >> >> > Jan 28 12:43:39 ubuntu dhclient: No DHCPOFFERS received.
>>> >>> >> >> >> > Jan 28 12:43:39 ubuntu dhclient: No working leases in
>>> >>> >> >> >> > persistent
>>> >>> >> >> >> > database -
>>> >>> >> >> >> > sleeping.
>>> >>> >> >> >> >
>>> >>> >> >> >> > Does anybody know how the VM template needs to be
>>> >>> >> >> >> > configured in
>>> >>> >> >> >> > order
>>> >>> >> >> >> > to
>>> >>> >> >> >> > get
>>> >>> >> >> >> > it working?
>>> >>> >> >> >> >
>>> >>> >> >> >> > Thanks in advance
>>> >>> >> >> >> > Wilma
>>> >>> >> >> >> >
>>> >>> >> >> >> >
>>> >>> >> >> >> > _______________________________________________
>>> >>> >> >> >> > Users mailing list
>>> >>> >> >> >> > Users at lists.opennebula.org
>>> >>> >> >> >> >
>>> >>> >> >> >> > http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>> >>> >> >> >> >
>>> >>> >> >> >>
>>> >>> >> >> >>
>>> >>> >> >> >>
>>> >>> >> >> >> --
>>> >>> >> >> >> Javier Fontán Muiños
>>> >>> >> >> >> Developer
>>> >>> >> >> >> OpenNebula - The Open Source Toolkit for Data Center
>>> >>> >> >> >> Virtualization
>>> >>> >> >> >> www.OpenNebula.org | @OpenNebula | github.com/jfontan
>>> >>> >> >> >
>>> >>> >> >> >
>>> >>> >> >>
>>> >>> >> >>
>>> >>> >> >>
>>> >>> >> >> --
>>> >>> >> >> Javier Fontán Muiños
>>> >>> >> >> Developer
>>> >>> >> >> OpenNebula - The Open Source Toolkit for Data Center
>>> >>> >> >> Virtualization
>>> >>> >> >> www.OpenNebula.org | @OpenNebula | github.com/jfontan
>>> >>> >> >
>>> >>> >> >
>>> >>> >>
>>> >>> >>
>>> >>> >>
>>> >>> >> --
>>> >>> >> Javier Fontán Muiños
>>> >>> >> Developer
>>> >>> >> OpenNebula - The Open Source Toolkit for Data Center Virtualization
>>> >>> >> www.OpenNebula.org | @OpenNebula | github.com/jfontan
>>> >>> >
>>> >>> >
>>> >>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>> Javier Fontán Muiños
>>> >>> Developer
>>> >>> OpenNebula - The Open Source Toolkit for Data Center Virtualization
>>> >>> www.OpenNebula.org | @OpenNebula | github.com/jfontan
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Javier Fontán Muiños
>>> > Developer
>>> > OpenNebula - The Open Source Toolkit for Data Center Virtualization
>>> > www.OpenNebula.org | @OpenNebula | github.com/jfontan
>>>
>>>
>>>
>>> --
>>> Javier Fontán Muiños
>>> Developer
>>> OpenNebula - The Open Source Toolkit for Data Center Virtualization
>>> www.OpenNebula.org | @OpenNebula | github.com/jfontan
>>
>>
>
>
>
> --
> Javier Fontán Muiños
> Developer
> OpenNebula - The Open Source Toolkit for Data Center Virtualization
> www.OpenNebula.org | @OpenNebula | github.com/jfontan



-- 
Javier Fontán Muiños
Developer
OpenNebula - The Open Source Toolkit for Data Center Virtualization
www.OpenNebula.org | @OpenNebula | github.com/jfontan


More information about the Users mailing list