diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-05-10 13:08:29 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-05-10 13:11:16 +0300 |
commit | 35db637a90bf3a1f5051828aea57c35f1593e3ca (patch) | |
tree | 91ec6770451380861f39e61e633c21a1a8af7e10 /ansible/roles | |
parent | 6840d9ea4a3f1620a988b4ac2afe08200510bb9d (diff) | |
download | ansibleness-35db637a90bf3a1f5051828aea57c35f1593e3ca.tar.gz |
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.
Diffstat (limited to 'ansible/roles')
-rw-r--r-- | ansible/roles/vmhost/tasks/main.yml | 8 |
1 files changed, 8 insertions, 0 deletions
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 |