LINBIT / virter

Virter is a command line tool for simple creation and cloning of virtual machines based on libvirt
Apache License 2.0
216 stars 11 forks source link

[Feature Request] Support bind mounts in container provisioner #16

Open C-512L opened 1 year ago

C-512L commented 1 year ago

One use case mentioned in docs/provisioning.md for the container provisioner is using a external provisioning tool such as ansible but there is no way to pass configuration/secrets (such as inventories and playbooks) to the running container.

JoelColledge commented 1 year ago

Thanks for the suggestion. I can imagine there could be use cases for custom bind mounts.

there is no way to pass configuration/secrets (such as inventories and playbooks) to the running container

Note that:

In addition, every container binds the following paths:

  • The current working directory of Virter, exposed read only at /virter/workspace
  • The SSH private key Virter used to connect to the machine as root at /root/.ssh/id_rsa
  • The SSH known hosts file, prefilled for connecting to the machine at /root/.ssh/known_hosts

These bind mounts have so far been sufficient for provisioning with ansible. Virter is run from the directory containing the playbooks. The SSH key is the secret required for accessing the VMs. The TARGETS environment variable is used to construct the inventory.

There is some work to do to glue that all together. I'm afraid I'm not aware of a publicly available example of how to do it.

Is that sufficient in your case?

C-512L commented 1 year ago

Note that:

In addition, every container binds the following paths:

  • The current working directory of Virter, exposed read only at /virter/workspace
  • The SSH private key Virter used to connect to the machine as root at /root/.ssh/id_rsa
  • The SSH known hosts file, prefilled for connecting to the machine at /root/.ssh/known_hosts

Thanks for pointing me out about the /virter/workspace mount. I don't know how but i had missed that part in the docs. Still, I think it could be quite useful for some cases like adding upper/external directories or for caching temporal files. This issue can be left open as a possible future improvement.