Run shell command on all Container/VMs

liszca

Well-Known Member
May 8, 2020
106
2
58
24
I like to have this command run on all my server: cat /etc/*relea*

Is this something the Proxmox Datacenter Manager help me with?
 
There's too little information about your server(s) and goals to help but you can write a simple loop to run this via either SSH or pct exec/qm guest exec. Or just issue it via ansible.
 
Last edited:
  • Like
Reactions: Johannes S
To your actual question: AFAIK PDM can't do that. It manages remotes, migration, updates etc., but can't run commands inside the guests. For this Ansible is really the way to go, especially if you need it more often. If you just want a quick look at your CTs, this loop on each node is enough:
Code:
for ct in $(pct list | awk 'NR>1 && $2=="running" {print $1}'); do echo "== CT $ct"; pct exec $ct -- cat /etc/os-release; done
For VMs qm guest exec <vmid> -- cat /etc/os-release only works if the qemu-guest-agent is installed and running in the VM, and you get the output back as JSON. Without the agent the only way into the VMs is SSH.