blob: 48cbb3a0f68682da5c85f2ae2a1c02be23064109 [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
Andy Bavier42eeab62016-07-01 16:48:57 -040035- name: Update apt cache
36 command: ansible services -m apt -b -u ubuntu -a "update_cache=yes"
Zack Williamsa3e40562016-07-05 12:05:39 -070037
Zack Williamsd31bbc92016-05-20 11:43:18 -070038- name: Update software in all the VMs
Andy Bavier42eeab62016-07-01 16:48:57 -040039 command: ansible services -m apt -b -u ubuntu -a "upgrade=dist"
Zack Williamsd31bbc92016-05-20 11:43:18 -070040
41- name: Create VM's eth0 interface config file for DNS config via resolvconf program
42 template:
43 src=eth0.cfg.j2
44 dest={{ ansible_user_dir }}/eth0.cfg
Andy Bavier0481a8a2016-07-14 13:01:45 +020045 when: not on_maas
Zack Williamsd31bbc92016-05-20 11:43:18 -070046
47- name: Copy eth0 interface config file to all VMs
48 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"
Andy Bavier0481a8a2016-07-14 13:01:45 +020049 when: not on_maas
Zack Williamsd31bbc92016-05-20 11:43:18 -070050
51- name: Restart eth0 interface on all VMs
52 command: ansible services -b -u ubuntu -m shell -a "ifdown eth0 ; ifup eth0"
Andy Bavier0481a8a2016-07-14 13:01:45 +020053 when: not on_maas
Zack Williamsd31bbc92016-05-20 11:43:18 -070054
55- name: Verify that we can log into every VM after restarting network interfaces
56 command: ansible services -m ping -u ubuntu
Andy Bavier0481a8a2016-07-14 13:01:45 +020057 when: not on_maas
Zack Williamsd31bbc92016-05-20 11:43:18 -070058
Zack Williams2cffa0f2016-05-20 12:18:47 -070059# sshkey is registered in head-prep task
Zack Williamse4fbacc2016-05-21 07:18:43 -070060- name: Enable root ssh login on VM's that require it
Zack Williams2cffa0f2016-05-20 12:18:47 -070061 command: ansible {{ item.name }} -b -u ubuntu -m authorized_key -a "user='root' key='{{ sshkey.stdout }}'"
62 with_items: "{{ head_vm_list | selectattr('root_ssh_login', 'defined') | list }}"
63
Zack Williams7d6747d2016-06-20 10:38:59 -070064- name: Copy over docker installation playbook and docker apt-key
Zack Williamse4fbacc2016-05-21 07:18:43 -070065 copy:
Zack Williams7d6747d2016-06-20 10:38:59 -070066 src="{{ item }}"
67 dest="{{ ansible_user_dir }}/{{ item }}"
68 with_items:
69 - "docker-install-playbook.yml"
70 - "docker_apt_key.gpg"
Zack Williamse4fbacc2016-05-21 07:18:43 -070071
72- name: Install docker in VM's that require it
Zack Williams9e74c4a2016-05-21 10:00:03 -070073 command: ansible-playbook "{{ ansible_user_dir }}/docker-install-playbook.yml"
Zack Williamse4fbacc2016-05-21 07:18:43 -070074