"""A ProxmoxVE VM template with Python""" import yaml from dotmap import DotMap import pulumi import pulumi_proxmoxve as proxmox conf = DotMap(yaml.safe_load(open("input.yaml").read())) config = pulumi.Config() provider = proxmox.Provider("proxmoxve", endpoint=conf.pve.url, insecure=conf.pve.insecure, username=conf.pve.username, password=config.require_secret("password") ) vm = proxmox.vm.VirtualMachine(conf.vm.name, node_name=conf.pve.nodename, agent = proxmox.vm.VirtualMachineAgentArgs( enabled = True, trim = True, type = "virtio" ), bios = "seabios", cpu = proxmox.vm.VirtualMachineCpuArgs( cores = conf.vm.cores, sockets = conf.vm.sockets ), memory = proxmox.vm.VirtualMachineMemoryArgs( dedicated = conf.vm.ram ), clone = proxmox.vm.VirtualMachineCloneArgs( node_name = conf.pve.nodename, vm_id = conf.vm.clone, full = True ), disks = [ proxmox.vm.VirtualMachineDiskArgs( interface = "virtio0", datastore_id = conf.pve.storage, size = conf.vm.disksize, file_format = "qcow2" ) ], network_devices = [ proxmox.vm.VirtualMachineNetworkDeviceArgs( bridge = "vmbr0", model = "virtio" ) ], on_boot = True, operating_system = proxmox.vm.VirtualMachineOperatingSystemArgs( type = "l26" ), initialization = proxmox.vm.VirtualMachineInitializationArgs( type = "nocloud", datastore_id = conf.pve.storage, user_account = proxmox.vm.VirtualMachineInitializationUserAccountArgs( username = conf.vm.username, password = conf.vm.password, keys = conf.vm.sshkeys ) ), opts = pulumi.ResourceOptions( provider = provider ) ) # Getting local IP # First item of the ipv4_addresses is of the loopback interface (so the usual 127.0.0.1). Let's get the second and grab only the text. lanip = vm.ipv4_addresses[1][0] pulumi.export("ip", lanip)