4

IP アドレスを cloud-init メタデータに渡す方法を探しています。そのため、qcow が起動するときに、120 秒から 180 秒も待つ必要はありません。

現在、cloud-init のユーザーデータ部分に IP アドレス情報を追加することで回避策を作成しました。欠点は、cloud-init ユーザーデータが 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

現在、cloud-init メタデータにホスト名を設定するために、この部分を既に取得しています。

cat > $config_dir/meta-data <<-EOF
instance-id: $uuid
hostname: $hostname
local-hostname: $hostname
EOF

しかし、cloud-init のドキュメントは非常にあいまいなので、もっと堅実で具体的なものが必要です

編集: Openstack がそれを実行できるため、それが可能であることがわかりました。

4

1 に答える 1