最后活跃于 4 months ago

drops 修订了这个 Gist 4 months ago. 转到此修订

1 file changed, 3 insertions, 1 deletion

gistfile1.md

@@ -62,4 +62,6 @@ sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
62 62 history -c
63 63 history -w
64 64 shutdown -h now
65 - ```
65 + ```
66 + * Mark VM as a Template
67 + * Test with Terraform

drops 修订了这个 Gist 4 months ago. 转到此修订

1 file changed, 16 insertions

gistfile1.md

@@ -47,3 +47,19 @@ EOL
47 47 # make the script executable
48 48 chmod +x /etc/rc.local
49 49 ```
50 + ```bash
51 + # cleanup apt
52 + apt clean
53 +
54 + # reset the machine-id (DHCP leases in 18.04 are generated based on this... not MAC...)
55 + echo "" | sudo tee /etc/machine-id >/dev/null
56 +
57 + # disable swap
58 + swapoff --all
59 + sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
60 +
61 + # cleanup shell history and shutdown for templating
62 + history -c
63 + history -w
64 + shutdown -h now
65 + ```

drops 修订了这个 Gist 4 months ago. 转到此修订

2 files changed, 49 insertions, 4 deletions

gistfile1.md(文件已创建)

@@ -0,0 +1,49 @@
1 + * Install Ubuntu Server (in this scenario 24.04.2 LTS) Minimized
2 + * Select Install OpenSSH server
3 + * Update and install necessary packages (or needed in template)
4 + ```bash
5 + apt update
6 + apt install open-vm-tools aptitude vim htop util-linux-extra -y
7 + apt upgrade -y
8 + ```
9 + * Disable `cloud-init`. NOTICE: Removing `cloud-init`, remove also necessary packages responsible for networking (e.g. netplan.io)
10 + ```bash
11 + cloud-init clean --logs
12 + touch /etc/cloud/cloud-init.disabled
13 + ```
14 + * Change `open-vm-tools` startup order
15 + ```bash
16 + sed -i 's/Before=cloud-init-local.service/After=dbus.service/g' /lib/systemd/system/open-vm-tools.service
17 + ```
18 + * Allow sudo without password
19 + ```bash
20 + sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g'
21 + ```
22 + * Cleanup VM for template
23 + ```bash
24 + # cleanup current ssh keys so templated VMs get fresh key
25 + sudo rm -f /etc/ssh/ssh_host_*
26 + ```
27 + ```bash
28 + # add check for ssh keys on reboot...regenerate if neccessary
29 + tee /etc/rc.local >/dev/null <<EOL
30 + #!/bin/sh -e
31 + #
32 + # rc.local
33 + #
34 + # This script is executed at the end of each multiuser runlevel.
35 + # Make sure that the script will "" on success or any other
36 + # value on error.
37 + #
38 + # In order to enable or disable this script just change the execution
39 + # bits.
40 + #
41 +
42 + # By default this script does nothing.
43 + test -f /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server
44 + exit 0
45 + EOL
46 +
47 + # make the script executable
48 + chmod +x /etc/rc.local
49 + ```

gistfile1.txt (文件已删除)

@@ -1,4 +0,0 @@
1 - Test bloku kodu
2 - ```
3 - mój kod
4 - ```

drops 修订了这个 Gist 4 months ago. 转到此修订

1 file changed, 4 insertions

gistfile1.txt(文件已创建)

@@ -0,0 +1,4 @@
1 + Test bloku kodu
2 + ```
3 + mój kod
4 + ```
上一页 下一页