add local deployement file
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
a163b7d1d8
commit
59860c54fc
1 changed files with 77 additions and 0 deletions
77
local.md
Normal file
77
local.md
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
```
|
||||
VPC_NAME = vpc-000000
|
||||
SUBNET_NAME = subnet-000000
|
||||
SUBNET_ID = 000000
|
||||
TAP_ID = 0
|
||||
DHCP = vpc-000000_br-000000.conf
|
||||
|
||||
ip netns add vpc-000000
|
||||
ip link add "veth-000000-ext" type veth peer name "veth-000000-int" netns "vpc-000000"
|
||||
brctl addbr "br-000000"
|
||||
brctl stp "br-000000" off
|
||||
ip netns exec "vpc-000000" brctl addbr "br-000000"
|
||||
ip netns exec "vpc-000000" brctl stp "br-000000" off
|
||||
|
||||
brctl addif "br-000000" "veth-000000-ext"
|
||||
ip netns exec "vpc-000000" brctl addif "br-000000" "veth-000000-int"
|
||||
|
||||
|
||||
brctl addif "br-000000" "eno1"
|
||||
|
||||
ip link set up dev "veth-000000-ext"
|
||||
ip link set up dev "br-000000"
|
||||
ip -n "vpc-000000" link set up dev "veth-000000-int"
|
||||
ip -n "vpc-000000" link set up dev "br-000000"
|
||||
|
||||
ebtables -A FORWARD --out-interface "br-000000" -p IPv4 --ip-protocol udp --ip-source-port 67:68 --ip-destination-port 67:68 -j DROP
|
||||
|
||||
|
||||
ip -n "vpc-000000" tuntap add dev "tap0" mode tap
|
||||
ip netns exec "vpc-000000" brctl addif "br-000000" "tap0"
|
||||
ip -n "vpc-000000" link set up dev "tap0"
|
||||
|
||||
VENDOR_DATA=$(
|
||||
cat <<END | sed -e ':a;N;$!ba;s/\n/\\n/g' | sed -e 's/"/\\"/g'
|
||||
#cloud-config
|
||||
users:
|
||||
- name: syonad
|
||||
lock_passwd: false
|
||||
gecos: Syonad urser
|
||||
groups: [adm, wheel, sudo]
|
||||
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
|
||||
shell: /bin/bash
|
||||
passwd: "$6$LD5z9v/s2b170Twj$pl1B/Mz0w8PCr7JhFcclQpBSxUQTDOiuPko8yf4LntEo8FrIo2yKVeHR6fb5VQpxX9NP2k9yhXdsp671Sc56u1"
|
||||
ssh_authorized_keys:
|
||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEL7V6RKvYPtzpk+Kb00e1mXiaqj8gZYIobavWQm1iBQ cardno:16_148_277
|
||||
END
|
||||
)
|
||||
|
||||
cat <<END > "/opt/metadata/vpc-000000_192.168.14.131-8081.conf"
|
||||
{
|
||||
"meta-data": "instance-id: vpc-000000\nlocal-hostname: test-vm\n",
|
||||
"user-data": "#!/bin/sh\npasswd -d root\n",
|
||||
"network-config": "version: 2\nethernets:\n eth0:\n dhcp4: true\n",
|
||||
"vendor-data": "${VENDOR_DATA}"
|
||||
}
|
||||
END
|
||||
systemctl status "metadata@vpc-000000_192.168.14.131-8081.service"
|
||||
|
||||
systemctl start "dnsmasq@vpc-000000_br-000000.service"
|
||||
|
||||
|
||||
|
||||
ip netns exec "vpc-000000" iptables -t nat -A PREROUTING -s "192.168.14.151/32" -d "169.254.169.254/32" -p tcp -m tcp --dport 80 -j DNAT --to-destination "192.168.14.131:8081"
|
||||
ip netns exec "vpc-000000" qemu-system-x86_64 \
|
||||
-enable-kvm \
|
||||
-cpu host \
|
||||
-m 1024 \
|
||||
-smp 1 \
|
||||
-serial "unix:/tmp/vm-3.sock,server,nowait" \
|
||||
-monitor "unix:/tmp/vm-3.mon-sock,server,nowait" \
|
||||
-qmp "unix:/tmp/vm-3.qmp-sock,server,nowait" \
|
||||
-display "none" \
|
||||
-drive "file=/disk/vm-3.qcow2,if=virtio" \
|
||||
-netdev "tap,id=net0,ifname=tap0,script=no,downscript=no" \
|
||||
-device "virtio-net-pci,netdev=net0,mac=00:22:33:00:00:01" \
|
||||
-daemonize
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue