-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-lxd-docker-vms
executable file
·80 lines (63 loc) · 1.54 KB
/
create-lxd-docker-vms
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
#!/usr/bin/env bash
set -ex
disk_size=100GB
memory_limit=12GB
cpu_limit=8
check_network(){
host=$1
until lxc exec $host -- bash -c "host google.com"; do
echo "Waiting for network connection"
sleep 5
done
}
create_vm(){
host=$1
lxc init ubuntu:focal $host --vm
lxc config set $host limits.cpu=$cpu_limit limits.memory=$memory_limit
lxc config device override $host root size=$disk_size
lxc start $host
lxc list $host
check_network $host
# sleep 10
# lxc exec $host -- snap install docker
# install_lxd $host
# install_docker_ce $host
}
install_lxd(){
host=$1
# lxc exec $host -- snap install lxd
lxc file push install-lxd $host/root/install-lxd
lxc exec $host -- /root/install-lxd
}
install_docker(){
host=$1
lxc file push install-docker $host/root/install-docker
# lxc exec $host -- snap install docker
lxc exec $host -- /root/install-docker
}
install_docker_ce(){
host=$1
lxc file push install-docker-ce $host/root/install-docker-ce
# lxc exec $host -- snap install docker
lxc exec $host -- /root/install-docker-ce
}
install_actions_runner(){
host=$1
lxc file push install-actions-runner $host/root/install-actions-runner
lxc exec $host -- /root/install-actions-runner
}
main(){
host_count=3
# for i in $(seq 1 $host_count); do
for i in $(seq 1 $host_count); do
host=d$i
lxc rm -f $host | true
create_vm $host
install_lxd $host
install_docker_ce $host
# install_actions_runner $host
done
}
main $@
# hosts
# lxc exec $host -- sudo snap install docker