6e72a2d376
As one of the community-wide goals, devstack has shifted to Ubuntu Jammy from Antelope cycle [1]. So, add playbooks for Jammy to installer. Although Focal support is still remained so that you can setup your environment on older version, but will be removed later. There are some additional updates. * Add bento as supported boxes which are well maintained more. * Use experimental Vagrant Disk to expand disk space on logical volume because for Ubuntu images of bento. * Change to use ssh key in ed25519 instead of rsa because it was deprecated in Jammy as default. [1] https://lists.openstack.org/pipermail/openstack-discuss/2022-October/030845.html Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com> Change-Id: I65b209a8ff2bd46adf2a4ee507ef7eee099d1b13
102 lines
2.3 KiB
Ruby
102 lines
2.3 KiB
Ruby
# Util method in vagrant-devstack
|
|
|
|
require "fileutils"
|
|
|
|
module VdUtils
|
|
|
|
# Get the contents of SSH public key to upload it to VMs.
|
|
def ssh_pub_key(config)
|
|
default_key_path = "~/.ssh/id_ed25519.pub"
|
|
|
|
if config["global"] != nil
|
|
if config["global"]["ssh_pub_key"]
|
|
key_path = File.expand_path(
|
|
config["global"]["ssh_pub_key"].gsub("$HOME", "~"))
|
|
end
|
|
end
|
|
|
|
key_path = File.expand_path(default_key_path) if key_path == nil
|
|
|
|
begin
|
|
ssh_pub_key = open(key_path).read.chomp
|
|
rescue => e
|
|
puts e
|
|
end
|
|
|
|
return ssh_pub_key
|
|
end
|
|
|
|
|
|
def setup_git_config()
|
|
src = "~/.gitconfig"
|
|
|
|
Dir.glob("roles/**/controller").each do |target_dir|
|
|
dst = "#{target_dir}/templates/gitconfig.j2"
|
|
|
|
gitconfig = File.expand_path src
|
|
if File.exists? gitconfig
|
|
FileUtils.copy(gitconfig, dst)
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
# Generate local ssh config file used by ssh with `-F` option.
|
|
def setup_ssh_config(config)
|
|
dst = File.expand_path "#{__dir__}/../ssh_config"
|
|
|
|
if config["machines"] != nil
|
|
entries = []
|
|
config["machines"].each do |m|
|
|
entries << {"Host" => m["hostname"],
|
|
"HostName" => m["private_ips"][0],
|
|
"User" => "stack"}
|
|
end
|
|
|
|
str = ""
|
|
entries.each do |ent|
|
|
ent.each do |k, v|
|
|
if k == "Host"
|
|
str += "#{k} #{v}\n"
|
|
else
|
|
str += " #{k} #{v}\n"
|
|
end
|
|
end
|
|
end
|
|
str.chomp
|
|
|
|
str += "Host *\n" +
|
|
" StrictHostKeyChecking no\n" +
|
|
" UserKnownHostsFile=/dev/null\n"
|
|
|
|
open(dst, "w+") {|f|
|
|
f.write(str)
|
|
}
|
|
end
|
|
end
|
|
|
|
# Return vagrant experimental features as a list.
|
|
def vagrant_experimentals()
|
|
res = []
|
|
if ENV["VAGRANT_EXPERIMENTAL"]
|
|
res = ENV["VAGRANT_EXPERIMENTAL"].split(",")
|
|
end
|
|
res
|
|
end
|
|
|
|
# Experimental feature "disks" can be enabled only for virtualbox provider and
|
|
# included in VAGRANT_EXPERIMENTAL env variable.
|
|
def is_disks_enabled(provider)
|
|
if provider == "virtualbox"
|
|
if vagrant_experimentals().include? "disks"
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
module_function :ssh_pub_key, :setup_git_config, :setup_ssh_config,
|
|
:vagrant_experimentals, :is_disks_enabled
|
|
|
|
end
|