From c4edd14b8aaf65d1db86074b0109b89ae609d4b3 Mon Sep 17 00:00:00 2001 From: binary Date: Wed, 2 Dec 2020 18:36:25 +0100 Subject: Refactor based on bhyve setup --- roles/vmm/tasks/main.yml | 64 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 15 deletions(-) (limited to 'roles/vmm/tasks/main.yml') diff --git a/roles/vmm/tasks/main.yml b/roles/vmm/tasks/main.yml index 81ddafc..3972e63 100644 --- a/roles/vmm/tasks/main.yml +++ b/roles/vmm/tasks/main.yml @@ -1,26 +1,60 @@ -# vmm_deploy ~~ tasks/main.yml +# vmm ~~ roles/vmm/tasks/main.yml +# vmm generation for hypervisor --- -- name: Check that iso directory exists +- name: ensure existence of vmm directories file: - path: "{{ vmm.iso_dir }}" + path: "{{ item }}" + owner: "{{ user_root }}" + group: "{{ group_root }}" + mode: 0770 state: directory - recurse: true + loop: + - "{{ vmm.dir }}" + - "{{ vmm.iso_dir }}" + - "{{ vmm.disk_dir }}" -- name: Check that disk directory exists - file: - path: "{{ vmm.disk_dir }}" - state: directory - recurse: true - -- name: Download all iso files - include: download_iso.yml iso={{ item }} +- name: download all iso files + include: isos.yml iso={{ item }} with_items: "{{ vmm.iso }}" -- name: Generate disks for all vms - include: generate_disk.yml guest={{ item }} +- name: generate disks for all vms + include: disks.yml guest={{ item }} with_items: "{{ vms }}" -- include: generate_vmconf.yml +- name: start ip forwarding + shell: sysctl net.inet.ip{{ item }}.forwarding=1 + loop: + - "" + - "6" + +- name: enable ip forwarding + lineinfile: + path: /etc/sysctl.conf + regexp: "^net.inet.ip{{ item }}.forwarding=" + line: "net.inet.ip{{ item }}.forwarding=1" + owner: "{{ user_root }}" + group: "{{ group_root }}" + create: yes + loop: + - "" + - "6" + +- name: create network switch + shell: echo "add {{ hypervisor.interface }}" > /etc/hostname.{{ vmm.switch.iface }} + +- name: start network switch + shell: "sh /etc/netstart {{ vmm.switch.iface }}" + +- name: generate vmm configuration + template: + src: templates/vm.conf.j2 + dest: "{{ vmm.config_file }}" + +- name: restart and enable vmd + service: + name: vmd + state: restarted + enabled: true -- cgit v1.2.3