forked from desrod/maas-autobuilder
-
Notifications
You must be signed in to change notification settings - Fork 1
/
user-data.yaml
120 lines (101 loc) · 2.8 KB
/
user-data.yaml
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
#cloud-config
ssh_import_id:
- lp:arif-ali
byobu_by_default: enable
timezone: "Europe/London"
# Allow ssh passwords
ssh_pwauth: True
## Update apt database and upgrade packages on first boot
package_update: true
package_upgrade: true
users:
- default
- name: virsh
lock_passwd: false
passwd: $6$SVOxUrhz9mNyscUJ$hKF0RMY1nkGC3BpiozpaznE3AWerd8Ac8AlV9YEpLx50bLw5zweFCuTEEdS04McJNlaIqA.E4HiPuaIYGMzlH/
shell: "/bin/rbash"
ssh_import_id:
- lp:arif-ali
## Install additional packages on first boot
packages:
- virtinst
- jq
- ksmtuned
- openvswitch-switch
snap:
commands:
- ['install', 'maas']
## Write arbitrary files to the file-system (including binaries!)
write_files:
- path: /root/initial_setup.sh
content: |
#!/bin/bash
git clone https://github.com/arif-ali/maas-autobuilder.git /root/maas-autobuilder
cd /root/maas-autobuilder/configs
ln -sf ${HOSTNAME}.config hypervisor.config
cd ../
chmod +x manage-vm-nodes.sh
./manage-vm-nodes.sh -c
permissions: '0755'
owner: root:root
- path: /root/install_kvm.sh
content: |
#!/bin/bash
series=$(lsb_release -c -s)
if [[ $series == "bionic" ]] ; then
pkgs="qemu-kvm libvirt-bin qemu-efi"
else
pkgs="libvirt-daemon-system libvirt-clients"
fi
apt -y update
apt -y install $pkgs
mkdir -p /home/virsh/bin
ln -s /usr/bin/virsh /home/virsh/bin/virsh
sh -c echo "PATH=/home/virsh/bin" >> /home/virsh/.bashrc
systemctl restart sshd
usermod -a -G libvirt,libvirt-qemu virsh
permissions: '0755'
owner: root:root
- path: /etc/ssh/sshd_config.d/90-virsh-user.conf
content: |
Match user virsh
X11Forwarding no
AllowTcpForwarding no
PermitTTY no
ForceCommand nc -q 0 -U /var/run/libvirt/libvirt-sock
owner: root:root
- path: /root/wipe_disk.sh
content: |
#!/bin/bash
dd if=/dev/zero of=/dev/sda bs=1M count=1000
permissions: '0755'
owner: root:root
- path: /etc/netplan/99-custom.yaml
content: |
network:
version: 2
ethernets:
enp1s0:
wakeonlan: true
link-local: []
enp2s0:
wakeonlan: true
link-local: []
enp3s0:
wakeonlan: true
link-local: []
permissions: '0644'
owner: root:root
- path: /etc/sysctl.d/99-custom.conf
content: |
kernel.softlockup_all_cpu_backtrace=1
permissions: '0644'
owner: root:root
# Runs any command that we need to run post install
runcmd:
- [ "/root/install_kvm.sh" ]
- [ "rm", "/root/install_kvm.sh" ]
- [ "/root/initial_setup.sh" ]
- [ "rm", "/root/initial_setup.sh" ]
- [ "netplan", "apply" ]
- [ "sysctl", "-p", "--system"]