Skip to content

Repository files navigation

cloudvirt

cloudvirt creates and destroys cloud-init powered x86_64 VMs using the libVirt API.

installation

1. stable

pip install cloudvirt

2. dev

git clone --depth=1 https://github.com/gottaeat/cloudvirt
cd cloudvirt/
pip install .

configuration

specification

domains

keynecessitydescription
dom_namerequiredstr name of the domain
dom_memrequiredint amount of memory in megabytes
dom_vcpurequiredint core count
netrequiredstr name of the libVirt network to associate with the VM
isolated_portoptionalbool whether port is isolated. If unset, relevant config not emitted.
vol_poolrequiredstr name of the libVirt pool to associate with the VM
vol_sizerequiredint disk size in gigabytes
base_imageoptionalstr full name of the cloud-init capable cloud image[1]
ipcheck[2]ipv4 ipv4 address or network to be associated with the primary interface of the VM
sshpwauthoptionalbool whether to allow ssh authentication via passwords (VM-wide, applies to all users)
gatewaycheck[3]ipv4 the next hop to the default route

[1] the cloud image specified must be present in the specified volume pool and be reachable by libVirt before cloudvirt is executed. if none provided, noble-server-cloudimg-amd64.img is expected to be present.

[2] if specified without a /, an attempt at DHCP and DNS reservation will be made. specifying a gateway makes providing a value for this key in CIDR notation necessary.

if there is no /, this address must be within the DHCP range of the libVirt network specified.

[3] installed as on-link. specifying this makes an ip to be supplied in CIDR notation necessary.

[2+3] these keys must be supplied with a value that abides by the requirements stated above if the network type for the specified libVirt network is not one of: router, nat

users

keynecessitydescription
namerequiredstr name of the user
password_hashoptionalstr password hash in shadow compliant crypt() format (like mkuser output)
ssh_keysoptionallist of str list of ssh keys to append to the authorized_keys of the user
sudo_god_moderequiredbool toggle for adding the user to the sudo group and allowing it to run sudo without a password

WARNING: if you do not specify any authentication method in the file supplied via --users and if you:

  1. do not specify an arbitrary user-data file via --userdata,
  2. or, specify a user-data but the resulting final cloud-inituser-data yaml to be written to the iso ends up having no valid authentication method

program will halt.

examples

--users <userspec.yml>

you can also do cloudvirt mkuser to interactively generate a userspec.yml through prompts.

---
userspec:
- name: johnpassword_hash: '$y$j9T$/gPg8H0fdtuZh8Ja8decf.$f7IzP89gNaToHUsY2bdgaxv2HJsKSRYLyG6mxNZ6AW3'sudo_god_mode: true
- name: doessh_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI0000000000000000000000000000000000000000000

<vmspec.yml>

---
vmspec:
dom_name: cloudvirttestdom_mem: 2048dom_vcpu: 2net: cloudvirt# isolated_port: no# ip:# gateway:vol_pool: cloudvirtvol_size: 10# base_image:# sshpwauth:

<pool.xml>

<pooltype="dir">
<name>cloudvirt</name>
<target>
<path>/pools/cloudvirt</path>
</target>
</pool>

<net.xml>

<network>
<name>cloudvirt</name>
<forwardmode="nat"/>
<ipaddress="192.168.253.1"netmask="255.255.255.0">
<dhcp>
<rangestart="192.168.253.1"end="192.168.253.254"/>
</dhcp>
</ip>
</network>

usage

cloudvirt --help

About

CloudVirt creates and destroys cloud-init powered x86_64 VMs utilizing the libVirt API.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages