Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network config alternative #30

Open
mariusrugan opened this issue Jan 20, 2019 · 3 comments
Open

Network config alternative #30

mariusrugan opened this issue Jan 20, 2019 · 3 comments

Comments

@mariusrugan
Copy link

mariusrugan commented Jan 20, 2019

Hi,

First of all, thanks for your work, really nice assembled, (however i'm trying master on a debian host, as a non root user, with all permissions given to libvirt, some vars fail to get assigned properly; i'll open a separate issue for that).
So in the light of the above, i had to cut down to a working solution and also solve static networking.

Wrt networking:

i'm using centos-atomic which at this moment has cloud-init version 18.2 https://cloudinit.readthedocs.io/en/18.2/

I'm adding to the ISO cloud-init image the following yaml file named network-config which gets picked up. Be aware that in cloud-init NoCloud this should NOT be under YAML node networking:
just the: version:1 config: .... works perfectly fine.
Again this is Cloud-Init dependent and works fine in my ATM latest centos atomic.

export NETWORK_CONFIG=/opt/kvm/ci/${VMNAME}/network-config
export CI_ISO=/opt/kvm/images/${VMNAME}-cidata.iso

sudo rm -rf ${NETWORK_CONFIG}
sync
sudo cat > ${NETWORK_CONFIG} << _EOF_
version: 1
config:
    - type: physical
      name: eth0
      mac_address: "${MAC}"
      subnets:
         - type: static
           address: 192.168.0.101
           netmask: 255.255.255.0
           gateway: 192.168.0.1
           network: 192.168.0.0
    - type: nameserver
      address: 
         - 192.168.0.254
      search:
         - mylocaldnsname.dev
_EOF_

sudo genisoimage -output ${CI_ISO} -volid cidata -joliet -rock ${USER_DATA} ${META_DATA} ${NETWORK_CONFIG}
@eayin2
Copy link

eayin2 commented Jul 30, 2019

You generated an image with your custom cloud-init configuration. Can you use the default image and instead run kvm-install-vm with -s (Custom shell script) to set the static IP? Creating a new ISO for each static IP seems time consuming.

@mariusrugan
Copy link
Author

mariusrugan commented Jul 30, 2019

Not really that time consuming @eayin2.

resizing my qcow2 images from 8 (default) to 32GB takes more time than generating this iso via genisoimage.

cloud-init uses user-data, network-config & metadata files which are needed in a readable format at boot time, in the vm. that's why the ISO. cloud-init is a widely adopted standard for configuring the virtual machines (from aws to my home-lab) and this is how it works.

from kvm perspective you're attaching a "virtual" drive from which it boots and there is no such abstraction of running a script when you start the vm.

alternatively you can edit the qcow2 images as explained here
https://medium.com/@farazfazli/libguestfs-cloud-init-kvm-provisioning-made-easy-17931d9ea8cf

[ Edit ]
i understand your remark now better because i've looked at the -s option.

https://github.com/giovtorres/kvm-install-vm/blob/master/kvm-install-vm#L454

and if you're referring to the runcmd part of cloud-init.
let's say that is ran amongst the last things cloud-init runs.
The vm's networking setup, you need it it way more earlier than runcmd.

but still, this script is still packaged in the iso, look into the deep-link above.

@eayin2
Copy link

eayin2 commented Jul 30, 2019

Yep I just saw it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants