From 6074f5e41e27e9cc749b5c8d6eb9608cef57395a Mon Sep 17 00:00:00 2001 From: jerick Date: Mon, 2 Feb 2026 13:58:18 -0500 Subject: [PATCH] Changed to finding template by id instead of name --- Jenkinsfile | 6 +++++- README.md | 14 ++++++++------ roles/proxmox_lxc/tasks/main.yml | 2 +- roles/proxmox_vm/tasks/main.yml | 3 ++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3804b55..a23288c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,6 +42,8 @@ pipeline { environment { ANSIBLE_HOST_KEY_CHECKING = 'False' ANSIBLE_FORCE_COLOR = 'true' + VM_TEMPLATE_ID = '133' + LXC_TEMPLATE_ID = '109' } stages { @@ -87,7 +89,9 @@ pipeline { -e "target_node=${params.TARGET_NODE}" \ -e "vm_hostname=${params.HOSTNAME}" \ -e "cpu_cores=${params.CPU_CORES}" \ - -e "ram_gb=${params.RAM_GB}" + -e "ram_gb=${params.RAM_GB}" \ + -e "vm_template_id=${VM_TEMPLATE_ID}" \ + -e "lxc_template_id=${LXC_TEMPLATE_ID}" """ } } diff --git a/README.md b/README.md index a6a9c47..bc5eef0 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ proxmox-template-clone/ - **Proxmox cluster** with token-based API authentication - **Jenkins server** with Ansible installed -- **Pre-built templates:** - - `ubuntu24vm` - Ubuntu 24 VM template - - `ubuntu24lxc` - Ubuntu 24 LXC template +- **Pre-built templates** (referenced by VMID): + - VM template (VMID: 133) + - LXC template (VMID: 109) - **Storage:** `local-lvm` backend for VM/LXC disks ### Jenkins Configuration @@ -123,9 +123,11 @@ Modify available nodes in the `Jenkinsfile` parameters section. ### Templates -Update template names in the respective role task files: -- [roles/proxmox_vm/tasks/main.yml](roles/proxmox_vm/tasks/main.yml) -- [roles/proxmox_lxc/tasks/main.yml](roles/proxmox_lxc/tasks/main.yml) +Template VMIDs are configured in the Jenkinsfile environment section: +- `VM_TEMPLATE_ID` - VMID of the VM template (currently: 133) +- `LXC_TEMPLATE_ID` - VMID of the LXC template (currently: 109) + +Update the values in the `environment` block of the Jenkinsfile to use different templates. ## License diff --git a/roles/proxmox_lxc/tasks/main.yml b/roles/proxmox_lxc/tasks/main.yml index 8ea1715..e0fc583 100644 --- a/roles/proxmox_lxc/tasks/main.yml +++ b/roles/proxmox_lxc/tasks/main.yml @@ -19,7 +19,7 @@ api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" node: "{{ target_node }}" - clone: "ubuntu24lxc" + clone: "{{ lxc_template_id }}" hostname: "{{ vm_hostname }}" vmid: "{{ next_vmid }}" full: true diff --git a/roles/proxmox_vm/tasks/main.yml b/roles/proxmox_vm/tasks/main.yml index d192044..ab5d557 100644 --- a/roles/proxmox_vm/tasks/main.yml +++ b/roles/proxmox_vm/tasks/main.yml @@ -19,7 +19,8 @@ api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" node: "{{ target_node }}" - clone: "ubuntu24vm" + vmid: "{{ vm_template_id }}" + clone: "template" name: "{{ vm_hostname }}" newid: "{{ next_vmid }}" full: true