Reputation: 16485
I have setup some VMs on a Hypervisor. Each of which is using a raw LVM Volume as disk. This way I can use LVM Snapshots to prepare a backup. Up to this point that is working and the only missing piece of the puzzle boils down to:
How can/should I do something like this with ansible:
dd bs=16M if=/dev/h-vg/vm-dev | ssh root@serverB "dd bs=16M of=/path/to/backup.img"
I know that I can first use dd
to create the image and than ansible.builtin.fetch
to pull it down. But than I would need three times as much hard disk space as the volume I want to backup, since I need space for the snapshot and additional space for the image.
I know that using the shell
module is an option (as always) but I want to make sure that there isn't any other more »ansibleish« way to do that, to avoid all the downsides of using the shell
module.
Piping data over ssh is some sort of general tool, but since ansible is managing all the »to and fro« I am curious if the is an ansible way to stream data like that.
Upvotes: 1
Views: 191
Reputation: 16485
To answer the question straight: There is no way in ansible to do something like the above without the usage of the shell
module. This comes with all the downsides when using the shell
module what shouldn't be used unless there is absolutely no other way around.
However, since my objective here was: »backing up KVM VMs« I found two alternative ways.
Mount a network volume (nfs, etc.) and use dd … of=/path/to/network/drive/…
This way the data will be copied over the network without piping it over ssh
Libvirt offers the ability to create backups (full and incremental) in »pull mode«. Going that way libvirt creates a »network block device (NBD)« which exposes a network block device, which in turn can be read from the target system.
Upvotes: 0