Changed inputs from yaml file.
This commit is contained in:
parent
b216e3361e
commit
91d8af9280
@ -1,5 +1,6 @@
|
|||||||
|
---
|
||||||
name: ${PROJECT}
|
name: ${PROJECT}
|
||||||
description: ${DESCRIPTION}
|
description: ${DESCRIPTION}
|
||||||
runtime: python
|
runtime: python
|
||||||
template:
|
template:
|
||||||
description: A minimal Python Pulumi program
|
description: A ProxmoxVE VM template with Python
|
||||||
|
7
pve-vm-python/README.md
Normal file
7
pve-vm-python/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Quick configuration #
|
||||||
|
|
||||||
|
Check out the file `input.yml` for a quick setup for a new machine.
|
||||||
|
Also, don't forget to setup the password for your account on your ProxmoxVE
|
||||||
|
server configuring `pulumi`:
|
||||||
|
|
||||||
|
$ pulumi config set password --secret yourpvepassword
|
@ -1,23 +1,24 @@
|
|||||||
"""A Pulumi-based infrastructure with Proxmox VE and Python"""
|
"""A ProxmoxVE VM template with Python"""
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
from dotmap import DotMap
|
||||||
import pulumi
|
import pulumi
|
||||||
import pulumi_proxmoxve as proxmox
|
import pulumi_proxmoxve as proxmox
|
||||||
|
|
||||||
|
conf = DotMap(yaml.safe_load(open("input.yaml").read()))
|
||||||
config = pulumi.Config()
|
config = pulumi.Config()
|
||||||
data = config.require_object("pve")
|
|
||||||
|
|
||||||
provider = proxmox.Provider("proxmoxve",
|
provider = proxmox.Provider("proxmoxve",
|
||||||
virtual_environment = {
|
virtual_environment = {
|
||||||
"endpoint": data.get("endpoint"),
|
"endpoint": conf.pve.url,
|
||||||
"insecure": True,
|
"insecure": conf.pve.insecure,
|
||||||
"username": "root@pam",
|
"username": conf.pve.username,
|
||||||
"password": data.get("password")
|
"password": config.require_secure("password")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
vm = proxmox.vm.VirtualMachine("vm",
|
vm = proxmox.vm.VirtualMachine(conf.vm.name,
|
||||||
name = "virtual-machine",
|
node_name = conf.pve.nodename,
|
||||||
node_name = data.get("node_name"),
|
|
||||||
agent = proxmox.vm.VirtualMachineAgentArgs(
|
agent = proxmox.vm.VirtualMachineAgentArgs(
|
||||||
enabled = True,
|
enabled = True,
|
||||||
trim = True,
|
trim = True,
|
||||||
@ -25,22 +26,22 @@ vm = proxmox.vm.VirtualMachine("vm",
|
|||||||
),
|
),
|
||||||
bios = "seabios",
|
bios = "seabios",
|
||||||
cpu = proxmox.vm.VirtualMachineCpuArgs(
|
cpu = proxmox.vm.VirtualMachineCpuArgs(
|
||||||
cores = 1,
|
cores = conf.vm.cores,
|
||||||
sockets = 1
|
sockets = conf.vm.sockets
|
||||||
),
|
),
|
||||||
memory = proxmox.vm.VirtualMachineMemoryArgs(
|
memory = proxmox.vm.VirtualMachineMemoryArgs(
|
||||||
dedicated = 2048
|
dedicated = conf.vm.ram
|
||||||
),
|
),
|
||||||
clone = proxmox.vm.VirtualMachineCloneArgs(
|
clone = proxmox.vm.VirtualMachineCloneArgs(
|
||||||
node_name = data.get("node_name"),
|
node_name = conf.pve.nodename,
|
||||||
vm_id = config.require("clonevm"),
|
vm_id = conf.vm.clone,
|
||||||
full = True
|
full = True
|
||||||
),
|
),
|
||||||
disks = [
|
disks = [
|
||||||
proxmox.vm.VirtualMachineDiskArgs(
|
proxmox.vm.VirtualMachineDiskArgs(
|
||||||
interface = "virtio0",
|
interface = "virtio0",
|
||||||
datastore_id = "local-lvm",
|
datastore_id = conf.pve.storage,
|
||||||
size = 20,
|
size = conf.vm.disksize,
|
||||||
file_format = "qcow2"
|
file_format = "qcow2"
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -56,15 +57,11 @@ vm = proxmox.vm.VirtualMachine("vm",
|
|||||||
),
|
),
|
||||||
initialization = proxmox.vm.VirtualMachineInitializationArgs(
|
initialization = proxmox.vm.VirtualMachineInitializationArgs(
|
||||||
type = "nocloud",
|
type = "nocloud",
|
||||||
datastore_id = "local-lvm",
|
datastore_id = conf.pve.storage,
|
||||||
user_account = proxmox.vm.VirtualMachineInitializationUserAccountArgs(
|
user_account = proxmox.vm.VirtualMachineInitializationUserAccountArgs(
|
||||||
username = "syntaxerrormmm",
|
username = conf.vm.username,
|
||||||
password = "cicciopasticcio",
|
password = conf.vm.password,
|
||||||
keys = [
|
keys = conf.vm.sshkeys
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFioHkaV1NhX6NCqsJakJw8EVBOcDHm1MEbpY499CPtG syntaxerrormmm@fisso",
|
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILu91hBh8pNRt4eE1pug0Y4jCHZDCcMJ+vj3CiF5EQHV syntaxerrormmm@syntaxxps",
|
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP/hn/0xn6DRS2B0paFzDQRakupgTQQ5hitQhqOfWcqz syntaxerrormmm@microbo"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
opts = pulumi.ResourceOptions(
|
opts = pulumi.ResourceOptions(
|
||||||
|
22
pve-vm-python/input.yaml
Normal file
22
pve-vm-python/input.yaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
pve:
|
||||||
|
url: "https://pve.vavassori.lcl:8006"
|
||||||
|
insecure: true
|
||||||
|
username: root@pam
|
||||||
|
nodename: pve
|
||||||
|
storage: local-lvm
|
||||||
|
|
||||||
|
# Basic VM configuration
|
||||||
|
vm:
|
||||||
|
name: virtual-machine
|
||||||
|
clone: 802
|
||||||
|
sockets: 1
|
||||||
|
cores: 1
|
||||||
|
ram: 2048
|
||||||
|
disksize: 20
|
||||||
|
username: syntaxerrormmm
|
||||||
|
password: cicciopasticcio
|
||||||
|
sshkeys:
|
||||||
|
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFioHkaV1NhX6NCqsJakJw8EVBOcDHm1MEbpY499CPtG syntaxerrormmm@fisso"
|
||||||
|
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILu91hBh8pNRt4eE1pug0Y4jCHZDCcMJ+vj3CiF5EQHV syntaxerrormmm@syntaxxps"
|
||||||
|
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP/hn/0xn6DRS2B0paFzDQRakupgTQQ5hitQhqOfWcqz syntaxerrormmm@microbo"
|
@ -1,2 +1,5 @@
|
|||||||
|
pyyaml>=6.0
|
||||||
|
protobuf==3.20.1
|
||||||
pulumi>=3.0.0,<4.0.0
|
pulumi>=3.0.0,<4.0.0
|
||||||
pulumi-proxmoxve>=2.0.0
|
pulumi-proxmoxve>=2.0.0
|
||||||
|
dotmap>=1.3.30
|
||||||
|
Loading…
Reference in New Issue
Block a user