add nsswhitch config for dns

This commit is contained in:
vincent 2023-11-12 11:04:09 +01:00
parent 6c0fb2e5f1
commit 4b284946e1

View File

@ -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