blob: 28350ef88cfa59821302f3d49b0e67474bf6c207 [file] [log] [blame]
Zack Williamsd31bbc92016-05-20 11:43:18 -07001---
2# file: create-vms/tasks/main.yml
3
Zack Williamsd31bbc92016-05-20 11:43:18 -07004- name: create Virtual Machines with uvt-kvm
5 shell: uvt-kvm create {{ item.name }} release={{ ansible_distribution_release }} \
6 --cpu={{ item.cpu }} --memory={{ item.memMB }} --disk={{ item.diskGB }} --bridge="mgmtbr"
7 creates=/var/lib/uvtool/libvirt/images/{{ item.name }}.qcow
8 with_items: "{{ head_vm_list }}"
9
10- name: Have VMs autostart on reboot
11 become: yes
12 virt:
13 name={{ item.name }}
14 command=autostart
15 with_items: "{{ head_vm_list }}"
16
17- name: wait for VM's to come up
18 wait_for:
19 host={{ item.name }}
20 port=22
21 with_items: "{{ head_vm_list }}"
22
23- name: Create /etc/ansible/hosts file
24 become: yes
25 template:
26 src=ansible_hosts.j2
27 dest=/etc/ansible/hosts
28
29- name: Verify that we can log into every VM
30 command: ansible services -m ping -u ubuntu
31
32- name: Have VM's use the apt-cache
33 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') }}\"; };'"
34
35- name: Update software in all the VMs
36 command: ansible services -m apt -b -u ubuntu -a "upgrade=dist update_cache=yes cache_valid_time=3600"
37
38- name: Create VM's eth0 interface config file for DNS config via resolvconf program
39 template:
40 src=eth0.cfg.j2
41 dest={{ ansible_user_dir }}/eth0.cfg
42
43- name: Copy eth0 interface config file to all VMs
44 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"
45
46- name: Restart eth0 interface on all VMs
47 command: ansible services -b -u ubuntu -m shell -a "ifdown eth0 ; ifup eth0"
48
49- name: Verify that we can log into every VM after restarting network interfaces
50 command: ansible services -m ping -u ubuntu
51
Zack Williams2cffa0f2016-05-20 12:18:47 -070052# sshkey is registered in head-prep task
Zack Williamse4fbacc2016-05-21 07:18:43 -070053- name: Enable root ssh login on VM's that require it
Zack Williams2cffa0f2016-05-20 12:18:47 -070054 command: ansible {{ item.name }} -b -u ubuntu -m authorized_key -a "user='root' key='{{ sshkey.stdout }}'"
55 with_items: "{{ head_vm_list | selectattr('root_ssh_login', 'defined') | list }}"
56
Zack Williams7d6747d2016-06-20 10:38:59 -070057- name: Copy over docker installation playbook and docker apt-key
Zack Williamse4fbacc2016-05-21 07:18:43 -070058 copy:
Zack Williams7d6747d2016-06-20 10:38:59 -070059 src="{{ item }}"
60 dest="{{ ansible_user_dir }}/{{ item }}"
61 with_items:
62 - "docker-install-playbook.yml"
63 - "docker_apt_key.gpg"
Zack Williamse4fbacc2016-05-21 07:18:43 -070064
65- name: Install docker in VM's that require it
Zack Williams9e74c4a2016-05-21 10:00:03 -070066 command: ansible-playbook "{{ ansible_user_dir }}/docker-install-playbook.yml"
Zack Williamse4fbacc2016-05-21 07:18:43 -070067