1 Commits

Author SHA1 Message Date
Râu Cao
401b03cc1e Use Ubuntu 22.04 for new VMs
Also, remove the custom config image generation and replace it with
`--cloud-init` options.
2024-06-07 20:53:20 +02:00
4 changed files with 16 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
node.default['bitcoin']['version'] = '27.1' node.default['bitcoin']['version'] = '26.0'
node.default['bitcoin']['checksum'] = '0c1051fd921b8fae912f5c2dfd86b085ab45baa05cd7be4585b10b4d1818f3da' node.default['bitcoin']['checksum'] = 'ab1d99276e28db62d1d9f3901e85ac358d7f1ebcb942d348a9c4e46f0fcdc0a1'
node.default['bitcoin']['username'] = 'satoshi' node.default['bitcoin']['username'] = 'satoshi'
node.default['bitcoin']['usergroup'] = 'bitcoin' node.default['bitcoin']['usergroup'] = 'bitcoin'
node.default['bitcoin']['network'] = 'mainnet' node.default['bitcoin']['network'] = 'mainnet'

View File

@@ -12,9 +12,8 @@ if node["bitcoin"]["blocksdir_mount_type"]
include_recipe "kosmos-bitcoin::blocksdir-mount" include_recipe "kosmos-bitcoin::blocksdir-mount"
end end
%w{ %w{ libtool autotools-dev make automake cmake curl g++-multilib libtool
libtool autotools-dev make automake cmake curl g++-10-multilib binutils-gold bsdmainutils pkg-config python3 patch }.each do |pkg|
binutils-gold bsdmainutils pkg-config python3 patch }.each do |pkg|
apt_package pkg apt_package pkg
end end
@@ -27,7 +26,7 @@ end
execute "compile_bitcoin-core_dependencies" do execute "compile_bitcoin-core_dependencies" do
cwd "/usr/local/bitcoind/depends" cwd "/usr/local/bitcoind/depends"
command "make CC=gcc-10 CXX=g++-10 NO_QT=1" command "make NO_QT=1"
action :nothing action :nothing
notifies :run, 'bash[compile_bitcoin-core]', :immediately notifies :run, 'bash[compile_bitcoin-core]', :immediately
end end
@@ -36,7 +35,7 @@ bash "compile_bitcoin-core" do
cwd "/usr/local/bitcoind" cwd "/usr/local/bitcoind"
code <<-EOH code <<-EOH
./autogen.sh ./autogen.sh
./configure CC=gcc-10 CXX=g++-10 --prefix=$PWD/depends/x86_64-pc-linux-gnu ./configure --prefix=$PWD/depends/x86_64-pc-linux-gnu
make make
EOH EOH
action :nothing action :nothing

View File

@@ -1,9 +1,9 @@
ubuntu_server_cloud_image_release = "20230506" release = "20240514"
node.default["kosmos_kvm"]["host"]["qemu_base_image"] = { node.default["kosmos_kvm"]["host"]["qemu_base_image"] = {
"url" => "https://cloud-images.ubuntu.com/releases/focal/release-#{ubuntu_server_cloud_image_release}/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img", "url" => "https://cloud-images.ubuntu.com/releases/jammy/release-#{release}/ubuntu-22.04-server-cloudimg-amd64-disk-kvm.img",
"checksum" => "27d2b91fd2b715729d739e2a3155dce70d1aaae4f05c177f338b9d4b60be638c", "checksum" => "2e7698b3ebd7caead06b08bd3ece241e6ce294a6db01f92ea12bcb56d6972c3f",
"path" => "/var/lib/libvirt/images/base/ubuntu-20.04-server-cloudimg-amd64-disk-kvm-#{ubuntu_server_cloud_image_release}.qcow2" "path" => "/var/lib/libvirt/images/base/ubuntu-22.04-server-cloudimg-amd64-disk-kvm-#{release}.qcow2"
} }
# A systemd.timer OnCalendar config value # A systemd.timer OnCalendar config value

View File

@@ -17,7 +17,7 @@ DISKSIZE=${4:-10} # 10GB default
# Directory where image files will be stored # Directory where image files will be stored
IMAGE_DIR=/var/lib/libvirt/images IMAGE_DIR=/var/lib/libvirt/images
IMAGE_PATH=$IMAGE_DIR/${VMNAME}.qcow2 IMAGE_PATH=$IMAGE_DIR/${VMNAME}.qcow2
CIDATA_PATH=${IMAGE_DIR}/cidata-${VMNAME}.iso CIDATA_PATH=${IMAGE_DIR}/${VMNAME}-cloudinit
BASE_FILE=<%= @base_image_path %> BASE_FILE=<%= @base_image_path %>
# Create the VM image if it does not already exist # Create the VM image if it does not already exist
@@ -38,9 +38,8 @@ qemu-img info "$IMAGE_PATH"
# Check if the cloud-init metadata file exists # Check if the cloud-init metadata file exists
# if not, generate it # if not, generate it
if [ ! -r $CIDATA_PATH ]; then if [ ! -r $CIDATA_PATH ]; then
pushd $(dirname $CIDATA_PATH) mkdir -p $CIDATA_PATH
mkdir -p $VMNAME pushd $CIDATA_PATH
cd $VMNAME
cat > user-data <<-EOS cat > user-data <<-EOS
#cloud-config #cloud-config
@@ -62,25 +61,19 @@ instance-id: $VMNAME
local-hostname: $VMNAME local-hostname: $VMNAME
EOS EOS
genisoimage -output "$CIDATA_PATH" -volid cidata -joliet -rock user-data meta-data
chown libvirt-qemu:kvm "$CIDATA_PATH"
chmod 600 "$CIDATA_PATH"
popd popd
fi fi
# setting --os-variant to ubuntu20.04 and ubuntu18.04 breaks SSH and networking
virt-install \ virt-install \
--name "$VMNAME" \ --name "$VMNAME" \
--ram "$RAM" \ --ram "$RAM" \
--vcpus "$CPUS" \ --vcpus "$CPUS" \
--cpu host \ --cpu host \
--arch x86_64 \ --arch x86_64 \
--os-type linux \ --osinfo detect=on,name=ubuntujammy \
--os-variant ubuntu16.04 \
--hvm \ --hvm \
--virt-type kvm \ --virt-type kvm \
--disk "$IMAGE_PATH" \ --disk "$IMAGE_PATH" \
--cdrom "$CIDATA_PATH" \
--boot hd \ --boot hd \
--network=bridge=virbr0,model=virtio \ --network=bridge=virbr0,model=virtio \
--graphics none \ --graphics none \
@@ -88,4 +81,5 @@ virt-install \
--console pty \ --console pty \
--channel unix,mode=bind,path=/var/lib/libvirt/qemu/$VMNAME.guest_agent.0,target_type=virtio,name=org.qemu.guest_agent.0 \ --channel unix,mode=bind,path=/var/lib/libvirt/qemu/$VMNAME.guest_agent.0,target_type=virtio,name=org.qemu.guest_agent.0 \
--autostart \ --autostart \
--import --import \
--cloud-init root-password-generate=off,disable=on,meta-data=$CIDATA_PATH/meta-data,user-data=$CIDATA_PATH/user-data