rhjhunt.libvirt_vm
libvirt-vm
Rôle Ansible pour installer une machine virtuelle libvirt sur un hyperviseur kvm RHEL/CentOS.
Exigences
- Ansible 2.9 ou supérieur
- Red Hat Enterprise Linux (RHEL) ou CentOS 7 ou 8
Variables du rôle
Les variables suivantes sont supportées pour ce rôle.
| Variable du rôle | Requis | Par défaut | Description | 
|---|---|---|---|
| libvirt_vm_ip | :x: | IP publique de la VM libvirt | |
| libvirt_vm_hostname | :heavy_check_mark: | FQDN de la VM | |
| libvirt_vm_root_pwd | :heavy_check_mark: | Mot de passe de l'utilisateur root | |
| libvirt_vm_base_img | :heavy_check_mark: | Nom de l'image de base | |
| libvirt_vm_storage_pool | :x: | default | Pool de stockage libvirt | 
| libvirt_vm_network | :heavy_check_mark: | Type de réseau pour la VM libvirt | |
| libvirt_vm_vcpus | :x: | 1 | Nombre de vCPU pour la VM | 
| libvirt_vm_ram | :x: | 1024 | Quantité de RAM en mégaoctets | 
| libvirt_vm_os_image_name | :x: | {{ libvirt_vm_hostname }} | Nom de l'image de la VM | 
| libvirt_vm_os_image_size | :x: | 10G | Taille de l'image du système d'exploitation de la VM | 
| libvirt_vm_os_variant | :x: | rhel8.1 | Variante OS libvirt | 
| libvirt_vm_nics | :heavy_check_mark: | voir exemple de playbook | Dictionnaire pour définir la NIC de la VM | 
Dépendances
Aucune
Exemple de Playbook
- hosts: hyperviseur
  tags: provision
  vars:
    libvirt_vm_hostname: "vm.example.com"
    libvirt_vm_root_pwd: "Pa$$w0rD!"
    libvirt_vm_base_img: rhel-guest-image-8.qcow2
    libvirt_vm_storage_pool: "default"
    libvirt_vm_network: "bridge=br0,model=virtio"
    libvirt_vm_vcpus: "2"
    libvirt_vm_ram: "4096"
    libvirt_vm_os_image_name: "{{ libvirt_vm_hostname }}"
    libvirt_vm_os_image_size: "20G"
    libvirt_vm_os_variant: "rhel8.1"
    libvirt_vm_nics:
      - name: eth0
        bootproto: static
        onboot: yes
        ip: "{{ libvirt_vm_ip }}"
        prefix: "24"
        gateway: "192.168.122.1"
        dns_server: "192.168.122.1"
  tasks:
    - name: Créer une VM libvirt
      include_role:
        name: rhjhunt.libvirt_vm
La VM libvirt peut également se voir attribuer une adresse DHCP.
- hosts: hyperviseur
  tags: provision
  vars:
    libvirt_vm_hostname: "vm.example.com"
    libvirt_vm_root_pwd: "Pa$$w0rD!"
    libvirt_vm_base_img: rhel-guest-image-8.qcow2
    libvirt_vm_storage_pool: "default"
    libvirt_vm_network: "bridge=br0,model=virtio"
    libvirt_vm_vcpus: "2"
    libvirt_vm_ram: "4096"
    libvirt_vm_os_image_name: "{{ libvirt_vm_hostname }}"
    libvirt_vm_os_image_size: "20G"
    libvirt_vm_os_variant: "rhel8.1"
    libvirt_vm_nics:
      - name: eth0
        bootproto: dhcp
        onboot: yes
  tasks:
    - name: Créer une VM libvirt
      include_role:
        name: rhjhunt.libvirt_vm
Licence
Informations sur l'auteur
Jacob Hunt jhunt@redhat.com
Installer
 ansible-galaxy install rhjhunt.libvirt_vmLicence
 
            gpl-3.0
          
Téléchargements
 
            81
          
Propriétaire
 