blob: f75501af4ae81c5f0c37bcbc5434b95b78dfd296 [file] [log] [blame]
Zack Williamsd31bbc92016-05-20 11:43:18 -07001---
2# file: create-vms/tasks/main.yml
3
4- name: Wait for uvt-kvm image to be available
5 async_status: jid={{ uvt_sync.ansible_job_id }}
6 register: uvt_sync_result
7 until: uvt_sync_result.finished
8 delay: 10
9 retries: 120
10
11- name: create Virtual Machines with uvt-kvm
12 shell: uvt-kvm create {{ item.name }} release={{ ansible_distribution_release }} \
13 --cpu={{ item.cpu }} --memory={{ item.memMB }} --disk={{ item.diskGB }} --bridge="mgmtbr"
14 creates=/var/lib/uvtool/libvirt/images/{{ item.name }}.qcow
15 with_items: "{{ head_vm_list }}"
16
17- name: Have VMs autostart on reboot
18 become: yes
19 virt:
20 name={{ item.name }}
21 command=autostart
22 with_items: "{{ head_vm_list }}"
23
24- name: wait for VM's to come up
25 wait_for:
26 host={{ item.name }}
27 port=22
28 with_items: "{{ head_vm_list }}"
29
30- name: Create /etc/ansible/hosts file
31 become: yes
32 template:
33 src=ansible_hosts.j2
34 dest=/etc/ansible/hosts
35
36- name: Verify that we can log into every VM
37 command: ansible services -m ping -u ubuntu
38
39- name: Have VM's use the apt-cache
40 command: ansible services -b -u ubuntu -m lineinfile -a "dest=/etc/apt/apt.conf.d/02apt-cacher-ng create=yes mode=0644 owner=root group=root regexp='^Acquire' line='Acquire::http { Proxy \"http://{{ apt_cacher_name }}:{{ apt_cacher_port | default('3142') }}\"; };'"
41
42- name: Update software in all the VMs
43 command: ansible services -m apt -b -u ubuntu -a "upgrade=dist update_cache=yes cache_valid_time=3600"
44
45- name: Create VM's eth0 interface config file for DNS config via resolvconf program
46 template:
47 src=eth0.cfg.j2
48 dest={{ ansible_user_dir }}/eth0.cfg
49
50- name: Copy eth0 interface config file to all VMs
51 command: ansible services -b -u ubuntu -m copy -a "src={{ ansible_user_dir }}/eth0.cfg dest=/etc/network/interfaces.d/eth0.cfg owner=root group=root mode=0644"
52
53- name: Restart eth0 interface on all VMs
54 command: ansible services -b -u ubuntu -m shell -a "ifdown eth0 ; ifup eth0"
55
56- name: Verify that we can log into every VM after restarting network interfaces
57 command: ansible services -m ping -u ubuntu
58