VMware Cloud Community
V00Z11
Enthusiast
Enthusiast

Cloud-init network config

Has anybody ever succeed in getting the network configuration for static IPs done with the native cloud-init network config part (not using write_files and run_cmd, but "network: [...]")

https://cloudinit.readthedocs.io/en/latest/reference/network-config.html

In my case the network configuration is currently handled using the "customizeGuestOs: true" flag. This is working von Ubuntu, RHEL and SLES.

However I wanted to try out the above mentioned way, because I have some specific routing configurations which I could set more easily that way. But neither the version 1 and 2 configs are working for me. Cloud-init seems to ignore that part and falls back to setting the first NIC to DHCP.

It would be great if anybody could share a working example. Thanks!

 

14 Replies
ronaldod
Enthusiast
Enthusiast

It is possible. It also depends on your linux flavor what config you need.

The network has to be defined in a separate definition. Look into metadata.

Some details you can find : https://cloudinit.readthedocs.io/en/latest/reference/datasources/vmware.html 

And if you want to go away from the OVF as data transport take a look at this. https://kb.vmware.com/s/article/91809 

It is a great read.

Enjoy.

 

 

0 Kudos
d3m1g0d
Enthusiast
Enthusiast

Afaik this cannot be achieved using the cloudConfig property in Aria Automation, as it is only user-data. See the statement in the cloud-init documentation link you've provided:

"User data cannot change an instance’s network configuration. In the absence of network configuration in any of the above sources, cloud-init will write out a network configuration that will issue a DHCP request on a “first” network interface."

0 Kudos
d3m1g0d
Enthusiast
Enthusiast

Yeah correct, nice read! You can overcome the OOTB limitation of cloudConfig being just user data using cloud-init's VMware datasource with guestinfo transport by leveraging am Extensibility Orchestrator workflow instead on relying on the default OVF datasource with the clunky ISO transport.

This raises the question if this is really easier than just using write_files and run_cmd within the cloudConfig property of a Cloud Template (I understood that it was a requirement of V00Z). But if you want to use cloud-init's network config, then this is the way...

Anyway, it would be really nice if the VMware datasource would make it into Aria Automation's OOTB functionality to be able to take advantage of it directly.

0 Kudos
V00Z11
Enthusiast
Enthusiast

I read the blog post too and it looks quite good, but complex too. I agree that this should become part of Aria Automation itself. Maybe at some point in the future. 

0 Kudos
ronaldod
Enthusiast
Enthusiast

It is not that complex. Just different.

Only the blog post is doing a part. You need to simplify it and add one variable.

If there is an interest i can make a small post how to implement it in a few steps (lniux only atm).

0 Kudos
wolficool
Contributor
Contributor

Í´am understanding right? In Aria Automation i just can use the cloud-init user-data like write_files, runcmd, fs_setup, bootcmd....

I cannot use the network metadata in a cloud template in the cloudconfig?..

So i should build the cloudconfig with the runcmd for customization, like hostname network config??

0 Kudos
ronaldod
Enthusiast
Enthusiast

If you like to have a lot of work. Or just implement the no-cd version. Just create a second variable and push it as meta into the vm.

0 Kudos
wolficool
Contributor
Contributor

Yeah ok, but these Option is not Official come from VMWare... I mean for Tests or not customer Environment it is ok to do. And also complex too..

It's very frustrating when this isn't well documented from VMWare that for now just cloud-init userdata can be integrated in cloud template in Aria Automation,

Anyway, it would be really great when you can create a small post how to implement the no-cd version 🙂

0 Kudos
KiranMuddaiahHP
Contributor
Contributor

You may consider referring to article  vRA with Cloud-init and Static Networking | vnuggets 

0 Kudos
wolficool
Contributor
Contributor

i have tried these from vnugget. for example: Hostname, Timezone works…, but Networkconfig is empty.

Which Modules are added in the Template in the cloud.cfg???

0 Kudos
ronaldod
Enthusiast
Enthusiast

You need to get creative for network.

That needs to be in a separate variable. And in the workflow you added to the guestinfo.metadata

Like i have a separate variable in the definition machine.

 

      twh_CloudConfig:
        local-hostname: ${self.resourceName}
        instance-id: ${self.resourceName}
        secret: ${secret.demo}
        network:
          version: 2
          ethernets:
            ens192:
              dhcp4: false
              gateway4: ${resource.Cloud_vSphere_Network_1.gateway}
              addresses:
                - ${resource.Cloud_Machine_1.networks[0].address}/${resource.Cloud_vSphere_Network_1.prefixLength}
              nameservers:
                search: twinhosting.class
                adresses: ${resource.Cloud_vSphere_Network_1.dns}

 

 
 
0 Kudos
wolficool
Contributor
Contributor

which sepwrate variable do you mean?? In the blueprint itself or for the guestinfo.metadata?

How you create the variable in cloud assembly for the guestinfo.metadata??

0 Kudos
ronaldod
Enthusiast
Enthusiast

The variable is created in the blueprint. Just any name you like.

And then in vRO you have a workflow that uses that variable. See previous posts about this from me.

0 Kudos