2019-04-09 17:42:12 +00:00
|
|
|
---
|
|
|
|
# tasks file for vmserver
|
|
|
|
- name: install composant
|
|
|
|
pacman:
|
2023-11-12 10:04:09 +00:00
|
|
|
state: present # not required. choices: absent;latest;present. Desired state of the package.
|
|
|
|
name:
|
|
|
|
- libvirt
|
|
|
|
- bridge-utils
|
|
|
|
- dmidecode
|
|
|
|
- dnsmasq
|
|
|
|
- ovmf
|
|
|
|
# To create virtual machines
|
2019-04-09 17:42:12 +00:00
|
|
|
become: yes
|
|
|
|
notify: Enable and start libvirt services
|
2023-11-12 10:04:09 +00:00
|
|
|
|
2019-04-09 17:42:12 +00:00
|
|
|
- name: Add user to libvirt group
|
|
|
|
user:
|
2019-04-11 16:54:12 +00:00
|
|
|
name: '{{ user.name }}'
|
2019-04-09 17:42:12 +00:00
|
|
|
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
|
|
|
|
|
2019-04-16 14:39:28 +00:00
|
|
|
- name: apply qemu.conf
|
|
|
|
template:
|
2020-11-28 16:09:42 +00:00
|
|
|
dest: /etc/libvirt/qemu.conf # required. Location to render the template to on the remote machine.
|
2019-04-16 14:39:28 +00:00
|
|
|
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
|
2019-04-09 17:42:12 +00:00
|
|
|
- debug:
|
2023-11-12 10:04:09 +00:00
|
|
|
msg: '{{ ansible_default_ipv4.type }}'
|
2019-04-09 17:42:12 +00:00
|
|
|
|
|
|
|
- name: set bridge template
|
|
|
|
template:
|
2023-11-12 10:04:09 +00:00
|
|
|
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.
|
2019-04-11 16:54:12 +00:00
|
|
|
when: ansible_default_ipv4.type == "ether" and "wlp2s0" not in ansible_interfaces
|
2019-04-09 17:42:12 +00:00
|
|
|
become: yes
|
2019-04-11 16:54:12 +00:00
|
|
|
notify: bridge_enable
|
|
|
|
|
2023-11-12 10:04:09 +00:00
|
|
|
- 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
|
2020-11-04 17:25:36 +00:00
|
|
|
- name: enable bridge
|
|
|
|
systemd:
|
|
|
|
name: netctl@bridge.service
|
2020-11-28 15:43:12 +00:00
|
|
|
enabled: true
|
2020-11-04 17:25:36 +00:00
|
|
|
become: yes
|
|
|
|
|
2019-04-11 16:54:12 +00:00
|
|
|
- name: disable dhcpcd
|
|
|
|
systemd:
|
|
|
|
name: dhcpcd # required. Name of the service.
|
|
|
|
enabled: false
|
|
|
|
become: yes
|