> For the complete documentation index, see [llms.txt](https://thorstenkramm.gitbook.io/saltstack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thorstenkramm.gitbook.io/saltstack/salt-cloud/kvm-und-libvirt.md).

# KVM und Libvirt

### Provider erstellen

Zuerst wird ein sogenannter Provider benötigt. Über diesen legen Sie fest, wie und ggf. mit welchen Zugangsdaten sich der Salt-Master zum Hypervisor verbindet.

{% code title="/etc/salt/cloud.providers.d/libvirt.conf" %}

```yaml
# Connect to a local libvirt instance       
local-kvm:
  driver: libvirt
  url: qemu:///system
  validate_xml: no
```

{% endcode %}

### Profil(e) erstellen

{% code title="/etc/salt/cloud.profiles.d/libvirt.conf" %}

```yaml
ubuntu:
  # points back at provider configuration
  provider: local-kvm
  ssh_username: hero
  sudo: True
  key_filename: '/dev/null'
  password: none
  base_domain: ubuntu1804
  ip_source: qemu-agent
  script_args: -F
  # script: LinuxMinimal # Use own script
  display_ssh_output: False
  minion:
    master: 192.168.122.1
debian:
  # points back at provider configuration
  provider: local-kvm
  ssh_username: root
  key_filename: '/dev/null'
  password: none
  base_domain: debian9
  ip_source: ip-learning
  script_args: -F
  display_ssh_output: False
  minion:
    master: 192.168.122.1
```

{% endcode %}

{% hint style="info" %}
Die Angabe von `key_filename` wird  ignoriert und es wird stattdessen `~/.ssh/id_rsa` verwendet. Trotzdem muss `key_filename` angegeben werden. Vielleicht wird dieser Bug in einer späteren Version behoben.
{% endhint %}
