Hi, got Proxmox installed. Now want to install some VMs but would like to use a simple setup rather than painfully going trough an install. I’ve read I could accomplish this via ansible. Are there ready playbooks you can hack? Presumably I would need to have Proxmox understand playbooks?

  • Zwuzelmaus@feddit.org
    link
    fedilink
    English
    arrow-up
    13
    ·
    2 days ago

    Besides ansible, also have a look at “templates” and “cloud-init” for VM generation.

    • Possibly linux@lemmy.zip
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 day ago

      I personally would avoid Cloud init as it is largely a Ubuntu thing.

      Instead look into Flatcar or bootable containers

  • mutual_ayed@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    10
    ·
    edit-2
    2 days ago

    NixOS and OpenTofu are pretty great. Add OpenBao to secure ssh keys and passwords and you can get a job as a sysops if you get good enough.

  • Possibly linux@lemmy.zip
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    1 day ago

    Start by creating a VM template in Proxmox. Male sure the template regenerates things like SSH host keys and machine-id on startup. Inside the template create a user with passwordless sudo and setup SSH public key authentication.

    One the host with the private key install Ansible in a python virtual environment.

    To execute this create a VM in proxmox, get its IP from the DHCP server and then add it to the hosts file for Ansible. From there you can use your playbooks.

    The automated way to do this would be to use the Ansible Proxmox collection to create the MAC of the VM and then use a different collection to fetch the IP and set it static. From there you could dynamically add it to the hosts file. This is hard and requires more Ansible knowledge.

    Another tool you could look into is pyinfra. Pyinfra has less of a learning curve since it is just python.

  • beerclue@lemmy.world
    link
    fedilink
    English
    arrow-up
    12
    ·
    2 days ago

    Oversimplifying it, Ansible playbooks are nothing more than some commands that should be run on a remote machine via ssh. Ansible knows or has modules for a variety of different package managers (apt, yum, etc) and automagically knows how to handle services or various config files.

    It can get complex, but I think just the startup phase, until you have an inventory of remote machines, the ssh keys are in place, etc. I second the Jeff Geerling recommendation, his stuff is solid, both ready to use playbooks, and tutorials.

    I would suggest to also look into cloudinit. Makes setting up VMs on proxmox easier, faster, more consistent, with users, networking, ssh keys, etc ready to use (by you or by Ansible).

    • chrisp@cyberplace.social
      link
      fedilink
      arrow-up
      2
      ·
      1 day ago

      @beerclue Exactly. You can take wiki bash instructions on how a system was set up and translate it to ansible, or back again. The ansible modules are python, but theoretically you could make a bash implementation that just calls dnf/systemctl/etc. directly, like a sys admin would have done.

    • IsoKiero@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 days ago

      Or, if you’re using only one or few distributions you can preseed the image and have the installer do the stuff for you.

  • irmadlad@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 day ago

    Watching this thread. I too would like to dip into Ansible. Looks like a really powerful way to automate things.

  • Justin@lemmy.jlh.name
    link
    fedilink
    English
    arrow-up
    7
    arrow-down
    1
    ·
    edit-2
    2 days ago

    Check out NixOS. It can build qcow images from scratch for you to import into proxmox

    https://github.com/nix-community/nixos-generators

    I have 8 bare-metal servers and I do everything automated with NixOS, I rarely ever access the servers directly.

    Here are the nixos configs for my DHCP server and kubernetes servers that you can use as a base.

    https://codeberg.org/jlh/h5b/src/branch/main/porygonz

    https://codeberg.org/jlh/h5b/src/branch/main/nodes

    For what it’s worth, Ive been using Ansible off and on at work for 8 years, and I think it’s pretty outdated and clunky these days, there are much smarter ways to manage workloads such as kubernetes, cloud-init, terraform, and NixOS. If you don’t want to get into Kubernetes then definitely learn NixOS.

  • just_another_person@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    2 days ago

    If you don’t want another dependency, just get familiar with the provisioning tools of whatever distro you intend to use (Fedora Kickstart, for example), and learn how to quickly provision custom scripted thing with cloud-init when you provision something.

  • solrize@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 days ago

    I use it to initialize new VPS with my usual setup, but it might be easier to use a container format. I think Ansible itself has become a bit unfashionable since I started using it. I don’t know what is cool instead now. It was Saltstack for a while but idk how long that lasted. Ansible is working mostly ok for me so I’ve stayed with it, til whenever.