From 4b284946e14325167fbd8f69e00d09b7d5a32b5d Mon Sep 17 00:00:00 2001 From: vincent Date: Sun, 12 Nov 2023 11:04:09 +0100 Subject: [PATCH] add nsswhitch config for dns --- tasks/main.yml | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 415670a..a448297 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,17 +2,17 @@ # tasks file for vmserver - name: install composant pacman: - state: present # not required. choices: absent;latest;present. Desired state of the package. - name: - - libvirt - - bridge-utils - - dmidecode - - dnsmasq - - ovmf - # To create virtual machines + state: present # not required. choices: absent;latest;present. Desired state of the package. + name: + - libvirt + - bridge-utils + - dmidecode + - dnsmasq + - ovmf + # To create virtual machines become: yes notify: Enable and start libvirt services - + - name: Add user to libvirt group user: name: '{{ user.name }}' @@ -33,16 +33,24 @@ src: qemu.conf.j2 # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path. become: yes - debug: - msg: "{{ ansible_default_ipv4.type }}" + msg: '{{ ansible_default_ipv4.type }}' - name: set bridge template template: - dest: /etc/netctl/bridge # required. Location to render the template to on the remote machine. - src: bridge.j2 # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path. + dest: /etc/netctl/bridge # required. Location to render the template to on the remote machine. + src: bridge.j2 # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path. when: ansible_default_ipv4.type == "ether" and "wlp2s0" not in ansible_interfaces become: yes notify: bridge_enable +- name: add libvirt to nsswitch hosts + ansible.builtin.lineinfile: + dest: '/etc/nsswitch.conf' + regexp: '^hosts:' + line: 'hosts: files libvirt libvirt_guest mymachines myhostname resolve [!UNAVAIL=return] dns' + state: present + create: true + become: true - name: enable bridge systemd: name: netctl@bridge.service @@ -54,4 +62,3 @@ name: dhcpcd # required. Name of the service. enabled: false become: yes - \ No newline at end of file