aboutsummaryrefslogtreecommitdiffstats
path: root/roles/vmm/tasks/main.yml
blob: 3972e632ef3f8bad85147700d2184fac1033aa8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

# vmm ~~ roles/vmm/tasks/main.yml
# vmm generation for hypervisor

---

- name: ensure existence of vmm directories
  file:
    path: "{{ item }}"
    owner: "{{ user_root }}"
    group: "{{ group_root }}"
    mode: 0770
    state: directory
  loop:
    - "{{ vmm.dir }}"
    - "{{ vmm.iso_dir }}"
    - "{{ vmm.disk_dir }}"

- name: download all iso files
  include: isos.yml iso={{ item }}
  with_items: "{{ vmm.iso }}"

- name: generate disks for all vms
  include: disks.yml guest={{ item }}
  with_items: "{{ vms }}"

- 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
remember that computers suck.