From 35db637a90bf3a1f5051828aea57c35f1593e3ca Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 10 May 2020 13:08:29 +0300 Subject: feat(roles/vmhost): install and use libnss-libvirt libnss-libvirt is a module for libnss that makes libvirt VM names available to the glibc NSS system. Result: create a VM and be able to ssh into it without looking up its IP, or adding it to /etc/hosts. --- ansible/roles/vmhost/tasks/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ansible/roles/vmhost/tasks') diff --git a/ansible/roles/vmhost/tasks/main.yml b/ansible/roles/vmhost/tasks/main.yml index e3dc288..59768f1 100644 --- a/ansible/roles/vmhost/tasks/main.yml +++ b/ansible/roles/vmhost/tasks/main.yml @@ -6,8 +6,16 @@ - virt-manager - libvirt-daemon-system - libvirt-clients + - libnss-libvirt - name: "enable nested KVM if possible" copy: src: kvm-nested.conf dest: /etc/modprobe.d/kvm-nested.conf + +- name: "add libvirt_guest to /etc/nsswitch.conf" + shell: | + if awk '$1 == "hosts:" && !/libvirt_guest/' /etc/nsswitch.conf | grep . + then + sed -i '/hosts:/s/files /files libvirt_guest /' /etc/nsswitch.conf + fi -- cgit v1.2.1