aboutsummaryrefslogblamecommitdiffstats
path: root/roles/vmm/tasks/main.yml
blob: 3972e632ef3f8bad85147700d2184fac1033aa8c (plain) (tree)
1
2
3
4
5
6
7
8
 

                                 


   
                                           
       



                             
                    



                          
 

                                  

                             

                                     

                         

































                                                                                     

# 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.