2014-11-06 20:42 GMT+01:00 Marek Marczykowski-Górecki
<
marm...@invisiblethingslab.com>:
> On Thu, Nov 06, 2014 at 08:59:27AM +0300,
johannes...@gmail.com wrote:
>> On Wednesday 05 November 2014 20:50:15 Marek Marczykowski-Górecki wrote:
>> > On Wed, Nov 05, 2014 at 05:33:07AM -0800,
johannes...@gmail.com wrote:
>> > > Hello,
>> > >
>> > > I'm setting out to manage an entire qubes setup using ansible.
How do you manage your vms via ansible? Did you write a plugin which
uses qvm-run?
>> > > One of the steps I would like to automate is to update the template
>> > > machines present.
I wrote a zsh script for this:
#!/usr/bin/env zsh
local -a targets
targets=( $( qvm-ls|grep Yes|cut -d'|' -f1,7|grep -v ' \- $'|tr -d '
{}[]<>='|cut -d'|' -f1) )
for t in $targets; do
if [[ $t == dom0 ]]; then
sudo qubes-dom0-update
else
print -P "%F{0}%K{7}[Updating $t]%k%f"
for tm in {xfce4-terminal,gnome-terminal,xterm}; do # we do
not know what kind of terminal is installed in the machine
qvm-run --auto -qp --user=root $t "$tm -e 'yum update -y'" && break
print -P "%K{1}Error in $t%k assuming $tm not found"
done
command qvm-shutdown $t
fi
done
wait
You are probably interested in line 3.
In general the qvm-ls tool is suboptimal. I noticed the following issues:
- There is no way to find out if a template needs to be updated (I
just grep all machines which are updateable, and just try to update
them)
- Each time i use qvm-ls my whole terminal explodes with thousand of
bar characters, if it's not wide enough.
- Also i miss the abillity to show only running machines.
So i wrote a ZSH script which displays the same information cleaner:
https://gist.github.com/kalkin/d2c1f837618294671267 (with qls -a it
shows all machines).
@Marek
Perhaps this would be a good output format, which could be adopted by
qvm-ls? I could come up with a patch if you like.
Sorry for partly hijacking this thread :). I hope i could help.
kalkin