virt/tasks/main.yml
2020-11-28 17:12:08 +01:00

57 lines
1.6 KiB
YAML

---
# 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
become: yes
notify: Enable and start libvirt services
- name: Add user to libvirt group
user:
name: '{{ user.name }}'
groups: libvirt
append: True
become: yes
- name: Enable libvirt hostname resolution
replace:
path: /etc/nsswitch.conf
regexp: '^hosts:\s+files\s+(?!libvirt)'
replace: 'hosts: files libvirt '
become: yes
- name: apply qemu.conf
template:
dest: /etc/libvirt/qemu.conf # required. Location to render the template to on the remote machine.
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 }}"
- 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.
when: ansible_default_ipv4.type == "ether" and "wlp2s0" not in ansible_interfaces
become: yes
notify: bridge_enable
- name: enable bridge
systemd:
name: netctl@bridge.service
enabled: true
become: yes
- name: disable dhcpcd
systemd:
name: dhcpcd # required. Name of the service.
enabled: false
become: yes