refactor ♻️: Refactored playbook to improve readability and maintainability
Simplified the playbook structure by removing unnecessary tasks and adding comments for clarity. Also, added a rescue block to handle potential errors during execution.
This commit is contained in:
@@ -8,12 +8,6 @@
|
|||||||
# 5. Clone creation & deployment
|
# 5. Clone creation & deployment
|
||||||
|
|
||||||
- name: "Create Debian VM template and deploy clones on Proxmox"
|
- name: "Create Debian VM template and deploy clones on Proxmox"
|
||||||
hosts: localhost
|
|
||||||
become: true
|
|
||||||
gather_facts: false
|
|
||||||
|
|
||||||
pre_tasks:
|
|
||||||
- name: "Display playbook banner"
|
|
||||||
debug:
|
debug:
|
||||||
msg: |
|
msg: |
|
||||||
╔════════════════════════════════════════════════════════════╗
|
╔════════════════════════════════════════════════════════════╗
|
||||||
@@ -23,13 +17,13 @@
|
|||||||
║ CPU: {{ cores }} cores | RAM: {{ memory }}MB ║
|
║ CPU: {{ cores }} cores | RAM: {{ memory }}MB ║
|
||||||
╚════════════════════════════════════════════════════════════╝
|
╚════════════════════════════════════════════════════════════╝
|
||||||
|
|
||||||
tasks:
|
|
||||||
##################################################################
|
##################################################################
|
||||||
# 1. PREFLIGHT CHECKS
|
# 1. PREFLIGHT CHECKS
|
||||||
##################################################################
|
##################################################################
|
||||||
- name: "STAGE 1: Run pre-flight environment checks"
|
- name: "STAGE 1: Run pre-flight environment checks"
|
||||||
include_tasks: preflight-checks.yml
|
include_tasks: preflight-checks.yml
|
||||||
tags: [preflight, always]
|
tags: [preflight, always]
|
||||||
|
run_once: true
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
# 2. DOWNLOAD IMAGE
|
# 2. DOWNLOAD IMAGE
|
||||||
@@ -68,7 +62,6 @@
|
|||||||
tags: [clones, create]
|
tags: [clones, create]
|
||||||
when: create_clones | default(false)
|
when: create_clones | default(false)
|
||||||
|
|
||||||
post_tasks:
|
|
||||||
- name: "Display completion summary"
|
- name: "Display completion summary"
|
||||||
debug:
|
debug:
|
||||||
msg: |
|
msg: |
|
||||||
@@ -86,10 +79,10 @@
|
|||||||
║ ║
|
║ ║
|
||||||
╚════════════════════════════════════════════════════════════╝
|
╚════════════════════════════════════════════════════════════╝
|
||||||
|
|
||||||
rescue:
|
# rescue:
|
||||||
- name: "Handle playbook errors"
|
# - name: "Handle playbook errors"
|
||||||
debug:
|
# debug:
|
||||||
msg: |
|
# msg: |
|
||||||
✗ Playbook execution failed
|
# ✗ Playbook execution failed
|
||||||
Check the error messages above for details.
|
# Check the error messages above for details.
|
||||||
You may need to manually clean up partially created VMs.
|
# You may need to manually clean up partially created VMs.
|
||||||
|
|||||||
Reference in New Issue
Block a user