-
Notifications
You must be signed in to change notification settings - Fork 4
/
simple_vm_create_new.yml
179 lines (168 loc) · 7.06 KB
/
simple_vm_create_new.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
- name: Simple vm deploy #edit vmname variable - use -l filter to specify cluster vs. full inventory
hosts: all
vars:
- vmname: testnew4
connection: ansible.builtin.local
gather_facts: false
strategy: host_pinned # free #allows each cluster to start next task before all clusters have finished current task
environment: #if set here - hypercore modules will automatically use this for each remote cluster - avoiding need to specify cluster_instance for each test
SC_HOST: "https://{{ inventory_hostname }}"
SC_USERNAME: "{{ scale_user }}"
SC_PASSWORD: "{{ scale_pass }}"
tasks:
# - name: Create project directory /tmp (if it doesn't exist already)
# file: state=directory path=~/tmp
# - name: Download ISO image from http://tinycorelinux.net/13.x/x86/release/TinyCore-current.iso and save it into /tmp/TinyCore-vm-integration.iso
# get_url: url=http://tinycorelinux.net/13.x/x86/release/TinyCore-current.iso dest=~/tmp/TinyCore-vm-integration.iso
- name: Upload ISO image TinyCore-vm-integration.iso to HyperCore API
scale_computing.hypercore.iso:
cluster_instance:
host: "https://{{inventory_hostname }}"
username: "{{scale_user}}"
password: "{{scale_pass}}"
name: "TinyCore-current.iso"
source: "/Users/davedemlow/Downloads/TinyCore-current.iso"
state: present
register: result
- name: Create and start the VM with disks, nics and boot devices set. Attach ISO onto the VM. Add cloud init data
scale_computing.hypercore.vm:
cluster_instance:
host: "https://{{inventory_hostname }}"
username: "{{scale_user}}"
password: "{{scale_pass}}"
vm_name: "{{ vmname }}"
description: Demo VM
state: present
tags:
- Xlab
- mytag1
- mytag2
memory: "{{ '512 MB' | human_to_bytes }}"
vcpu: 2
# attach_guest_tools_iso: true
power_state: start
disks:
# - type: ide_cdrom
# disk_slot: 0
# iso_name: ""
- type: ide_cdrom
disk_slot: 1
iso_name: ""
- type: virtio_disk
disk_slot: 0
size: "{{ '10.1 GB' | human_to_bytes }}"
nics:
- vlan: 1
type: RTL8139
- vlan: 2
type: virtio
boot_devices:
- type: ide_cdrom
disk_slot: 0
- type: virtio_disk
disk_slot: 0
- type: nic
nic_vlan: 1
cloud_init:
user_data: |
#cloud-config
password: "password"
chpasswd: { expire: False }
ssh_pwauth: True
apt: {sources: {docker.list: {source: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable', keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88}}}
packages: [qemu-guest-agent, docker-ce, docker-ce-cli, docker-compose, ansible, git, unzip]
snap:
commands:
00: snap install semaphore
01: snap install edgexfoundry
02: snap install edgex-ui
03: snap install edgex-cli
04: snap install edgex-device-camera
05: snap install edgex-device-mqtt
06: snap install edgex-device-rest
bootcmd:
- [ sh, -c, 'sudo echo GRUB_CMDLINE_LINUX="nomodeset" >> /etc/default/grub' ]
- [ sh, -c, 'sudo echo GRUB_GFXPAYLOAD_LINUX="1024x768" >> /etc/default/grub' ]
- [ sh, -c, 'sudo echo GRUB_DISABLE_LINUX_UUID=true >> /etc/default/grub' ]
- [ sh, -c, 'sudo update-grub' ]
runcmd:
- [ systemctl, restart, --no-block, qemu-guest-agent ]
write_files:
# configure docker daemon to be accessible remotely via TCP on socket 2375
- content: |
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375
path: /etc/systemd/system/docker.service.d/options.conf
meta_data: |
dsmode: local
local-hostname: "{{ vmname }}"
machine_type: BIOS
register: vm_created
# - name: Create and configure ad hoc "{{ vmname }}"
# scale_computing.hypercore.vm_clone:
# vm_name: "{{vmname}}"
# memory: "{{ '4 GB' | human_to_bytes }}"
# description:
# tags:
# - "{{vmname}}"
# - ansible
# - "{{ site_name }}"
# - ansible_group__"{{vmname}}" # this will create tag used by hypercore inventory plugin when executing towards VM hosts
# vcpu: 4
# power_state: start
# cloud_init:
# user_data: |
# #cloud-config
# password: "password"
# chpasswd: { expire: False }
# ssh_pwauth: True
# apt: {sources: {docker.list: {source: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable', keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88}}}
# packages: [qemu-guest-agent, docker-ce, docker-ce-cli, docker-compose, ansible, git, unzip]
# snap:
# commands:
# 00: snap install semaphore
# 01: snap install edgexfoundry
# 02: snap install edgex-ui
# 03: snap install edgex-cli
# 04: snap install edgex-device-camera
# 05: snap install edgex-device-mqtt
# 06: snap install edgex-device-rest
# bootcmd:
# - [ sh, -c, 'sudo echo GRUB_CMDLINE_LINUX="nomodeset" >> /etc/default/grub' ]
# - [ sh, -c, 'sudo echo GRUB_GFXPAYLOAD_LINUX="1024x768" >> /etc/default/grub' ]
# - [ sh, -c, 'sudo echo GRUB_DISABLE_LINUX_UUID=true >> /etc/default/grub' ]
# - [ sh, -c, 'sudo update-grub' ]
# runcmd:
# - [ systemctl, restart, --no-block, qemu-guest-agent ]
# write_files:
# # configure docker daemon to be accessible remotely via TCP on socket 2375
# - content: |
# [Service]
# ExecStart=
# ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375
# path: /etc/systemd/system/docker.service.d/options.conf
# meta_data: |
# dsmode: local
# local-hostname: "{{ vmname }}"
# - name: Disk desired configuration for "{{ vmname }}"
# scale_computing.hypercore.vm_disk:
# vm_name: "{{ vmname }}"
# items:
# - disk_slot: 0
# type: virtio_disk
# size: "{{ '100 GB' | human_to_bytes }}" # 50GB | human to bytes results in 53.7GB VSD in Hypercore
# state: present
# - name: Vm desired configuration and state for "{{ vmname }}"
# scale_computing.hypercore.vm_params:
# vm_name: "{{vmname}}"
# memory: "{{ '4 GB' | human_to_bytes }}"
# description:
# tags:
# - "{{vmname}}"
# - ansible
# - "{{ site_name }}"
# - ansible_group__"{{vmname}}" # this will create tag used by hypercore inventory plugin when executing towards VM hosts
# vcpu: 4
# power_state: start