# What is needed to make Cloud-Init and OpenNebula work?

**URL:** <https://forum.opennebula.io/t/what-is-needed-to-make-cloud-init-and-opennebula-work/1316>\
**Category:** Product Support\
**Created:** [October 13, 2015, 4:26am UTC](https://forum.opennebula.io/t/what-is-needed-to-make-cloud-init-and-opennebula-work/1316 "2015-10-13T04:26:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamdev12](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@jamdev12](https://forum.opennebula.io/u/jamdev12)\
**Post date:** [October 13, 2015, 4:26am UTC](https://forum.opennebula.io/t/what-is-needed-to-make-cloud-init-and-opennebula-work/1316/1 "2015-10-13T04:26:53Z")

</div>

Hi all,

Hopefully someone can help me with this request. First the setup:

vCenter environment running 5.5  
OpenNebula 4.14 (from source)  
vCenter template with CentOS 6.7 prepped with one-context-4.14.rpm and Cloud-Init 0.7.5  
Using the below template to deploy VM:

```
CONTEXT=[
 SET_HOSTNAME="testvm003.staging4",
 ETH0_DNS="10.16.1.135 10.16.1.136",
 ETH0_GATEWAY="10.26.1.1",
 ETH0_IP="10.26.1.94",
 ETH0_MASK="255.255.255.0",
 ETH0_NETWORK="10.26.1.0",
 ETH0_SEARCH_DOMAIN="staging4",
 NETWORK="YES",
 DNS_HOSTNAME="YES",
 SSH_PUBLIC_KEY="ssh-rsa blahblahblah jmalena@host123",
 USER_DATA="#cloud-config
runcmd:
  - mkdir -p /usr/local/test
  - touch /usr/local/test/file.out " ]
NAME = "testvm003.staging4"
CPU = 2
VCPU = 2
MEMORY = 2048
GRAPHICS=[
  LISTEN="0.0.0.0",
  TYPE="vnc" ]
HYPERVISOR="vcenter"
NIC=[
  NETWORK="VLAN_101_10_26_1_0 - SJCCLUSTER",
  NETWORK_UNAME="oneadmin" ]
PUBLIC_CLOUD=[
 TYPE="vcenter",
 VM_TEMPLATE="42218aad-096a-a487-820d-c9ac9d018af5" ]
SCHED_REQUIREMENTS="NAME=\"SJCCLUSTER\""

```

Here is the generated [context.sh](http://context.sh) file in the deployed VM:

```
# Context variables generated by OpenNebula
DISK_ID='0'
DNS_HOSTNAME='YES'
ETH0_DNS='10.16.1.135 10.16.1.136'
ETH0_GATEWAY='10.26.1.1'
ETH0_IP='10.26.1.92'
ETH0_MAC='02:00:63:8e:2a:08'
ETH0_MASK='255.255.255.0'
ETH0_NETWORK='10.26.1.0'
ETH0_SEARCH_DOMAIN='staging4'
NETWORK='YES'
SET_HOSTNAME='testvm001.staging4'
SSH_PUBLIC_KEY='ssh-rsa blahblahblah jmalena@host123'
TARGET='hda'
USER_DATA='#cloud-config
runcmd:
  - mkdir -p /usr/local/test
  - touch /usr/local/test/file.out '

```

Now the problem:

The contextualization of the VM works, but what does not work is the Cloud-Init section. I can’t seem to figure out what I’m doing wrong. From what I can tell is that a route is placed in the interface eth0 configuration for the network 169.254.0.0/16. The VM tries to communicate with the IP address 169.254.169.254 to obtain its metadata information. This information is locally on the server via the /tmp/context.sh script that was generated during the deployment of the VM, but this data doesn’t seem to be getting to Cloud-Init. Am I missing something? Does cloud.cfg in /etc/cloud/ in the VM template need to be configured differently than the default? I have tried the below setup with different options for dsmode. I have tried net and local and they don’t work:

```
disable_ec2_metadata: True
datasource_list: ['OpenNebula']
datasource:
  OpenNebula:
    dsmode: net
    parseuser: nobody

```

Thanks in advance,  
Jesus

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [October 16, 2015, 2:35pm UTC](https://forum.opennebula.io/t/what-is-needed-to-make-cloud-init-and-opennebula-work/1316/2 "2015-10-16T14:35:14Z")

</div>

`cloud-init` does not work with OpenNebula using the `vcenter` as the way of contextualizing the VM is a little bit different. Instead of attaching a CDROM with `context.sh` the information is retrieved using vmwaretools.

You should use only one method of contextualization, with `vcenter` use OpenNebula context packages alone. To execute some commands in the machine you can use `START_SCRIPT`. For example:

```bash
CONTEXT = [
  NETWORK="YES",
  START_SCRIPT="mkdir -p /usr/local/test
touch /usr/local/test/file.out"
]

```

---

<div class="post-metadata">

**Author:** ![jamdev12](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@jamdev12](https://forum.opennebula.io/u/jamdev12)\
**Post date:** [October 16, 2015, 5:43pm UTC](https://forum.opennebula.io/t/what-is-needed-to-make-cloud-init-and-opennebula-work/1316/3 "2015-10-16T17:43:44Z")

</div>

HIi Javi,

Thank you for letting me know that this does not work, but that there is a work around with START\_SCRIPT. I have gone ahead and tested this and I can definitely run it this way. I was thinking that this was impossible to do, but now I can setup and install chef-client and my systems are getting configured properly via Chef, which was my ultimate goal. Thank you for the hint. Now we can setup OpenNebula in our infrastructure and replace OpenStack. 😄

One more thing, support for OpenNebula. Where can I buy it? How much does it cost? How does this play into new features down the road, say if my company wanted a feature that currently is not in OpenNebula? One more question, if the choice was between OpenNebula, or vOneCloud, which would be the best one for a vCenter infrastructure, but with the ability to phase out VMware in the future?

Thanks,  
Jesus

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [October 19, 2015, 9:41am UTC](https://forum.opennebula.io/t/what-is-needed-to-make-cloud-init-and-opennebula-work/1316/4 "2015-10-19T09:41:47Z")

</div>

Nice it works for you. There’s also the variable `START_SCRIPT_BASE64`. This is decoded by the context packages in case you need to add a more complex script:

[http://docs.opennebula.org/4.14/user/virtual\_machine\_setup/cong.html#using-user-template-variables](http://docs.opennebula.org/4.14/user/virtual_machine_setup/cong.html#using-user-template-variables)

[OpenNebula Systems](http://opennebula.systems/) can give you the support and professional services needed. Please, send an email to [contact@opennebula.systems](http://mailto:contact@opennebula.systems) and one of my colleagues will be in touch.

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [October 19, 2015, 9:44am UTC](https://forum.opennebula.io/t/what-is-needed-to-make-cloud-init-and-opennebula-work/1316/5 "2015-10-19T09:44:04Z")

</div>

Oh, forgot about the OpenNebula vOneCloud question. If you are planning to use also KVM or Xen you should better use OpenNebula as vOneCloud comes with those drivers, and some sunstone features disabled. They can be enabled editing configuration files but in the next upgrade they will be disabled again.

---

<div class="post-metadata">

**Author:** ![ranjith](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ranjith/32/5081_2.png) [@ranjith](https://forum.opennebula.io/u/ranjith)\
**Post date:** [April 12, 2017, 8:20am UTC](https://forum.opennebula.io/t/what-is-needed-to-make-cloud-init-and-opennebula-work/1316/6 "2017-04-12T08:20:52Z")

</div>

Why cloud-init is not supported in Opennebula. What is the better alternative to this? How to do this?
