forked from nefeli/ansible-kvm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
playbook.yml
71 lines (68 loc) · 1.57 KB
/
playbook.yml
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
61
62
63
64
65
66
67
68
69
70
71
---
- hosts: all
gather_facts: no
tasks:
- name: update apt cache
apt:
update_cache: yes
cache_valid_time: 3600
- hosts: all
tasks:
- name: download test image
get_url:
url: "https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img"
dest: /tmp/ubuntu.img
# VM with empty disk
- hosts: all
become: true
vars:
kvm_config: true
kvm_manage_vms: true
kvm_disable_apparmor: true
kvm_vms:
- name: 'testhost1'
autostart: true
boot_devices:
- 'hd'
memory: '512'
state: 'running'
vcpu: '1'
disks:
- disk_driver: 'virtio'
name: 'testhost1-disk'
size: '36864'
network_interfaces:
- source: 'default'
network_driver: 'virtio'
type: 'network'
roles:
- role: ansible-kvm
# VM with a defined disk config
- hosts: all
become: true
vars:
kvm_config: true
kvm_manage_vms: true
kvm_disable_apparmor: true
kvm_vms:
- name: 'testhost2'
autostart: true
boot_devices:
- 'hd'
memory: '512'
state: 'running'
vcpu: '1'
disks:
- disk_driver: 'virtio'
name: 'testhost2-disk'
image: '/tmp/ubuntu.img'
size: '8192'
# cdroms:
# - source: /tmp/example.iso
network_interfaces:
- source: 'default'
network_driver: 'virtio'
type: 'network'
slot: '5'
roles:
- role: ansible-kvm