Aggiornato template con ultime impostazioni e test.

This commit is contained in:
Emiliano Vavassori 2024-04-26 00:10:48 +02:00
parent 6a6327b4c5
commit 4059be838d
5 changed files with 29 additions and 22 deletions

View File

@ -2,5 +2,10 @@
name: ${PROJECT} name: ${PROJECT}
description: ${DESCRIPTION} description: ${DESCRIPTION}
runtime: python runtime: python
template: template:
description: ProxmoxVE provider, Ansible powered with Python description: ProxmoxVE provider, Ansible powered with Python
config:
password:
description: Password of the root user over PVE.
secret: true

View File

@ -1,3 +1,6 @@
[![Deploy with Pulumi](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://git.sys42.eu/syntaxerrormmm/pulumi-templates/src/branch/main/pvm-ansible)
# Quick configuration # # Quick configuration #
Check out the file `input.yml` for a quick setup for a new machine. Check out the file `input.yml` for a quick setup for a new machine.

View File

@ -4,29 +4,28 @@ import pulumi
import pulumi_proxmoxve as proxmox import pulumi_proxmoxve as proxmox
import pulumi_command as command import pulumi_command as command
import yaml import yaml
from dotmap import DotMap
# Import configuration parameters from input.yaml # Import configuration parameters from input.yaml
i = open("./input.yaml") input_ = DotMap(yaml.safe_load(open("./input.yaml", "r").read()))
input_ = yaml.safe_load(i.read())
i.close()
# Check pulumi configuration # Check pulumi configuration
config = pulumi.Config() config = pulumi.Config()
provider = proxmox.Provider("proxmoxve", provider = proxmox.Provider("proxmoxve",
endpoint=input_['pve']['url'], endpoint=input_.pve.url,
insecure=input_['pve']['insecure'], insecure=input_.pve.insecure,
username=input_['pve']['username'], username=input_.pve.username,
password=config.require_secret("password") password=config.require_secret("password")
) )
vm_name = input_['vm']['name'] vm_name = input_.vm.name
vm_username = input_['vm']['username'] vm_username = input_.vm.username
ansible_playbook = input_['ansible_playbook'] ansible_playbook = input_.ansible_playbook
vm = proxmox.vm.VirtualMachine("vm", vm = proxmox.vm.VirtualMachine("vm",
name = vm_name, name = vm_name,
node_name = input_['pve']['nodename'], node_name = input_.pve.nodename,
agent = proxmox.vm.VirtualMachineAgentArgs( agent = proxmox.vm.VirtualMachineAgentArgs(
enabled = True, enabled = True,
trim = True, trim = True,
@ -34,22 +33,20 @@ vm = proxmox.vm.VirtualMachine("vm",
), ),
bios = "seabios", bios = "seabios",
cpu = proxmox.vm.VirtualMachineCpuArgs( cpu = proxmox.vm.VirtualMachineCpuArgs(
cores = input_['vm']['cores'], cores = input_.vm.cores,
sockets = input_['vm']['sockets'] sockets = input_.vm.sockets
),
memory = proxmox.vm.VirtualMachineMemoryArgs(
dedicated = input_['vm']['ram']
), ),
memory = proxmox.vm.VirtualMachineMemoryArgs(dedicated = input_.vm.ram),
clone = proxmox.vm.VirtualMachineCloneArgs( clone = proxmox.vm.VirtualMachineCloneArgs(
node_name = input_['pve']['nodename'], node_name = input_.pve.nodename,
vm_id = input_['vm']['clone'], vm_id = input_.vm.clone,
full = True full = True
), ),
disks = [ disks = [
proxmox.vm.VirtualMachineDiskArgs( proxmox.vm.VirtualMachineDiskArgs(
interface = "virtio0", interface = "virtio0",
datastore_id = input_['pve']['storage'], datastore_id = input_.pve.storage,
size = input_['vm']['disksize'], size = input_.vm.disksize,
file_format = "raw" file_format = "raw"
) )
], ],
@ -65,11 +62,11 @@ vm = proxmox.vm.VirtualMachine("vm",
), ),
initialization = proxmox.vm.VirtualMachineInitializationArgs( initialization = proxmox.vm.VirtualMachineInitializationArgs(
type = "nocloud", type = "nocloud",
datastore_id = input_['pve']['storage'], datastore_id = input_.pve.storage,
user_account = proxmox.vm.VirtualMachineInitializationUserAccountArgs( user_account = proxmox.vm.VirtualMachineInitializationUserAccountArgs(
username = vm_username, username = vm_username,
password = input_['vm']['password'], password = input_.vm.password,
keys = input_['vm']['sshkeys'] keys = input_.vm.sshkeys
) )
), ),
opts = pulumi.ResourceOptions( opts = pulumi.ResourceOptions(

View File

@ -20,6 +20,7 @@ vm:
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFioHkaV1NhX6NCqsJakJw8EVBOcDHm1MEbpY499CPtG syntaxerrormmm@fisso" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFioHkaV1NhX6NCqsJakJw8EVBOcDHm1MEbpY499CPtG syntaxerrormmm@fisso"
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILu91hBh8pNRt4eE1pug0Y4jCHZDCcMJ+vj3CiF5EQHV syntaxerrormmm@syntaxxps" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILu91hBh8pNRt4eE1pug0Y4jCHZDCcMJ+vj3CiF5EQHV syntaxerrormmm@syntaxxps"
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILH5q/ObtC4VhNT88gebezP/svpvCoQLoZCh4DvUn4xq syntaxerrormmm@taz" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILH5q/ObtC4VhNT88gebezP/svpvCoQLoZCh4DvUn4xq syntaxerrormmm@taz"
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGdTHkPCPUhvrcGgU9M6/BaEeirStM/kBnFxsLyXyelt syntaxerrormmm@kurotsuchi"
# Ansible configuration # Ansible configuration
ansible_playbook: deploy.yml ansible_playbook: deploy.yml

View File

@ -1,3 +1,4 @@
pulumi>=3.0.0,<4.0.0 pulumi>=3.0.0,<4.0.0
pulumi-proxmoxve>=2.0.0 pulumi-proxmoxve>=2.0.0
pulumi-command>=0.4.1 pulumi-command>=0.4.1
dotmap>=1.3.30