Files
ansible-inventories/proxmox_inventory.yml

52 lines
1.2 KiB
YAML

---
- name: Gather Full Machine Inventory from Proxmox Nodes
hosts: proxmox_nodes
become: true
gather_facts: true
tasks:
- name: Gather VM list
command: qm list
register: vm_list
- name: Gather Container list
command: pct list
register: ct_list
- name: Gather storage status
command: pvesm status
register: storage_status
- name: Gather node status
command: pvesh get /nodes/$(hostname)/status
register: node_status
- name: Gather hardware info
command: pveversion -v
register: hardware_info
- name: Save inventory to file
copy:
content: |
Node: {{ inventory_hostname }}
Ansible Facts: {{ ansible_facts | to_nice_yaml }}
VMs:
{{ vm_list.stdout }}
Containers:
{{ ct_list.stdout }}
Storage Status:
{{ storage_status.stdout }}
Node Status:
{{ node_status.stdout | from_json | to_nice_yaml }}
Hardware Info:
{{ hardware_info.stdout }}
dest: /tmp/proxmox_inventory_{{ inventory_hostname }}.txt
- name: Debug
debug:
msg: "Inventory saved to /tmp/proxmox_inventory_{{ inventory_hostname }}.txt"