62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
"""A ProxmoxVE Container 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")
|
|
)
|
|
|
|
ct=proxmox.ct.Container(conf.ct.name,
|
|
console=proxmox.ct.ContainerConsoleArgs(enabled=True),
|
|
cpu=proxmox.ct.ContainerCpuArgs(cores=conf.ct.cores),
|
|
disk=proxmox.ct.ContainerDiskArgs(
|
|
datastore_id=conf.ct.storage,
|
|
size=conf.ct.disksize
|
|
),
|
|
initialization=proxmox.ct.ContainerInitializationArgs(
|
|
hostname=conf.ct.name,
|
|
ip_configs=[
|
|
proxmox.ct.ContainerInitializationIpConfigArgs(
|
|
ipv4=proxmox.ct.ContainerInitializationIpConfigIpv4Args(
|
|
address="dhcp"
|
|
)
|
|
)
|
|
],
|
|
user_account=proxmox.ct.ContainerInitializationUserAccountArgs(
|
|
password=conf.ct.password,
|
|
keys=conf.ct.sshkeys
|
|
),
|
|
),
|
|
memory=proxmox.ct.ContainerMemoryArgs(
|
|
dedicated=conf.ct.ram,
|
|
swap=conf.ct.ram
|
|
),
|
|
network_interfaces=[
|
|
proxmox.ct.ContainerNetworkInterfaceArgs(
|
|
name="eth0",
|
|
bridge="vmbr0",
|
|
enabled=True
|
|
)
|
|
],
|
|
node_name=conf.pve.nodename,
|
|
operating_system=proxmox.ct.ContainerOperatingSystemArgs(
|
|
template_file_id=f"local:vztmpl/{conf.ct.template}",
|
|
type=conf.ct.template_type
|
|
),
|
|
started=True,
|
|
opts=pulumi.ResourceOptions(
|
|
provider=provider
|
|
)
|
|
)
|
|
|
|
pulumi.export("id", ct.id)
|