Skip to content

OsgiliathEnterprise/ansible-virtualization-guest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible virtualization Guest

  • Galaxy: Ansible Galaxy
  • Lint & requirements: Molecule
  • Tests: Build Status
  • Chat: Join the chat at https://gitter.im/OsgiliathEnterprise/platform

This role is a wrapper on top of The StackHpc VM guest role and permit to deploy a Virtual Machine on libvirt/kvm. The cool thing with this role is that you can grab any box you want from vagrant cloud: it will download it, start it with libvirt/kvm, override the vagrant default user and it's ssh key by the one of the user executing to the role on the guest. It will copy its ssh key and add it to sudoers/nologin. Finally, it will configure firewalld on the host to let you have access to the guest machine

It also supports Bridged and Natted interfaces

Requirements

tox -e pipdep and check [pip requirements] (./requirements.txt) or [pip dev requirements] (./requirements-dev.txt)

Role Variables

Same as the one of the original role

Also, your should reference some remotely hosted libvirt compliant boxes

    virtualization_guest_boxes:
      - name: fedoraGuestVM
        url: https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-33-1.2.x86_64.vagrant-libvirt.box
        memory_mb: 2048
        vcpus: 1
        recreate_machine: true # mandatory should recreate or not?
        ssh_port_on_host: 6752 # port configured as NATTED on the host (port 6752 on the host will be redirected to port 22 on the guest)
        vm_ssh_key_url: # URL of the key insecure packer key to download
        ansible_groups:
          - directory
          - openid
        size: 3GB # Optionnal
        interfaces:
          - network: default
      - name: fedoraGuestVM2
        url: https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-33-1.2.x86_64.vagrant-libvirt.box
        memory_mb: 2048
        vcpus: 1
        recreate_machine: true # mandatory should recreate or not?
        vm_ssh_key_url: # URL of the key insecure packer key to download
        size: 3GB # Optionnal
        interfaces:
          - type: bridge
            source:
              dev: eth0

More information on the according variables in molecule test and defaults variables

These boxes will be unpacked in /var/lib/libvirt/images/{{ box.name }}.img so that you'll be able to reference it to create your vm

Known surprising behaviours

  • This role won't recreate vm that are not taggued by recreate_machine: true even if they are marked as undefine in virsh. It will persist the list of created VM in a persistent fact that you should edit/remove /etc/ansible/facts.d/ansible_virtualization_guest.fact.

Dependencies

See: requirements collection and requirements standalone

Example Playbook

License

Apache-2

Author Information