Created
July 26, 2023 08:05
-
-
Save phixion/43ef6b68b5a578b77a551f56c2584255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multipass launch -n testvm -mem --cpu 1 --disk 5G --memory 2G 22.04 --cloud-init ~/.config/cloud-init.yml -v | |
ip_addr=$(multipass info testvm | awk '/IPv4/ {print $NF}') | |
ssh "ubuntu@${ip_addr}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cloud-config | |
output: {all: '| tee -a /var/log/cloud-init-output.log'} # stored inside vm | |
timezone: "Etc/UTC" | |
# RHEL/CentOS | |
# manage-resolv-conf: true | |
# resolv_conf: | |
# nameservers: | |
# - '1.1.1.1' | |
# - '1.0.0.1' | |
# TODO: debug nameservers | |
# Debian/Ubuntu (netplan) | |
network: | |
version: 2 | |
ethernets: | |
eno1: | |
dhcp4: true | |
nameservers: | |
addresses: [1.1.1.1, 1.0.0.1] | |
package_update: true # default: true | |
package_upgrade: false # default: false | |
package_reboot_if_required: true | |
apt: | |
sources: | |
docker.list: | |
source: deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable | |
keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 | |
packages: | |
- apt-transport-https | |
- bash-completion | |
- ca-certificates | |
- curl | |
- docker-ce | |
- docker-ce-cli | |
- gnupg-agent | |
- python3 | |
- python3-pip | |
- software-properties-common | |
- ssh-import-id | |
- tree | |
- vim | |
users: | |
- default | |
- name: ubuntu | |
gecos: Ubuntu | |
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | |
home: /home/ubuntu | |
groups: [adm, audio, cdrom, docker, libvirt, lxd, netdev, sudo] | |
lock_passwd: true | |
shell: /bin/bash | |
no_ssh_fingerprints: true | |
ssh_authorized_keys: | |
- ssh-rsa AAAABBBCCCDDDEEE== username@hostname | |
write_files: | |
- path: /home/ubuntu/.bashrc | |
content: | | |
# custom | |
alias update='sudo apt update && sudo apt upgrade && sudo apt dist-upgrade && sudo apt autoremove && sudo apt auto-clean' | |
append: true | |
- path: /home/ubuntu/.bash_profile | |
content: | | |
[[ -s ~/.bashrc ]] && source ~/.bashrc | |
- path: /etc/systemd/system/container.service | |
owner: root:root | |
permissions: '0755' | |
content: | | |
[Unit] | |
Description=Run container | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
ExecStartPre=-/usr/bin/docker rm container | |
ExecStart=/usr/bin/docker run --rm --name container hello-world | |
ExecStop=/usr/bin/docker stop -t 2 container | |
runcmd: | |
- systemctl start container | |
- systemctl enable container | |
final_message: "The system is finally up, after $UPTIME seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment