小编Jon*_*cht的帖子

将IP地址传递给cloud-init元数据

我正在寻找一种将ip-address传递给cloud-init元数据的方法.因此,当我的qcow启动时,它不必等待120 - 180秒启动.

目前,我已经通过将IP地址信息添加到cloud-init的userdata部分来创建了一种解决方法.问题是,它确实需要一些时间,因为cloud-init userdata仅在引导VM后执行.

echo -e "
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
\taddress $address
\tnetmask $netmask
\tgateway $gateway
\tdns-nameservers $dnsnameservers
" > /etc/network/interfaces

ifdown eth0; ifup eth0
Run Code Online (Sandbox Code Playgroud)

目前要在cloud-init元数据中设置主机名,我已经获得了这个部分:

cat > $config_dir/meta-data <<-EOF
instance-id: $uuid
hostname: $hostname
local-hostname: $hostname …
Run Code Online (Sandbox Code Playgroud)

linux bash kvm openstack cloud-init

4
推荐指数
1
解决办法
8959
查看次数

标签 统计

bash ×1

cloud-init ×1

kvm ×1

linux ×1

openstack ×1