virt/tasks/main.yml

52 lines
1.5 KiB
YAML
Raw Normal View History

2019-04-09 17:42:12 +00:00
---
# 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
- qemu-headless
2019-04-16 14:39:28 +00:00
- ovmf
2019-04-09 17:42:12 +00:00
# To create virtual machines
become: yes
notify: Enable and start libvirt services
- 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:
dest: /etc/libvirt # 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
2019-04-09 17:42:12 +00:00
- debug:
2019-04-10 18:27:12 +00:00
msg: "{{ ansible_default_ipv4.type }}"
2019-04-09 17:42:12 +00:00
- 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.
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
- name: disable dhcpcd
systemd:
name: dhcpcd # required. Name of the service.
enabled: false
become: yes