Created
November 14, 2022 15:18
-
-
Save mehmetaydogduu/b8a7021cec407193bc646bfe317be137 to your computer and use it in GitHub Desktop.
rancher-ubuntu-22.04-jammy-cloud-init
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 | |
network: | |
config: disabled | |
users: | |
- name: ubuntu | |
shell: /bin/bash | |
groups: wheel | |
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | |
ssh_authorized_keys: | |
- $publickey1 | |
- $publickey2 | |
plain_text_passwd: $password | |
- name: root | |
shell: /bin/bash | |
groups: wheel | |
sudo: ['ALL=(ALL) NOPASSWD:ALL'] | |
ssh_authorized_keys: | |
- $publickey1 | |
- $publickey2 | |
plain_text_passwd: $password | |
write_files: | |
- path: /ubuntu/set_network.sh | |
content: | | |
#!/bin/bash | |
vmtoolsd --cmd 'info-get guestinfo.ovfEnv' > /tmp/ovfenv | |
IPAddress=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.ip.0.address" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv) | |
SubnetMask=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.ip.0.netmask" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv) | |
Gateway=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.route.0.gateway" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv) | |
DNS=$(sed -n 's/.*Property oe:key="guestinfo.dns.servers" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv) | |
cat > /etc/netplan/50-cloud-init.yaml <<EOF | |
network: | |
version: 2 | |
ethernets: | |
nics: | |
match: | |
name: ens* | |
link-local: [] | |
dhcp4: false | |
addresses: | |
- $IPAddress/24 | |
nameservers: | |
addresses : [$DNS] | |
routes: | |
- to: 0.0.0.0/0 | |
via: $Gateway | |
EOF | |
sudo netplan apply | |
runcmd: | |
- bash /ubuntu/set_network.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment