From: David Galloway Date: Thu, 28 May 2026 20:22:06 +0000 (-0400) Subject: builder.yml: Reinstall vagrant(-libvirt) if needed X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=81e38dda545b34ac4c3872303cb706b6eacfdda3;p=ceph-build.git builder.yml: Reinstall vagrant(-libvirt) if needed Avoids: ``` Vagrant failed to properly resolve required dependencies. These errors can commonly be caused by misconfigured plugin installations or transient network issues. The reported error is: nokogiri requires Ruby version >= 3.2, < 4.1.dev. The current ruby version is 2.7.4.191. ``` Which happens when an old vagrant version is installed on a builder then the version of vagrant provided in the chacra repo is newer. Signed-off-by: David Galloway --- diff --git a/ansible/examples/builder.yml b/ansible/examples/builder.yml index b347396ea..50f922144 100644 --- a/ansible/examples/builder.yml +++ b/ansible/examples/builder.yml @@ -548,6 +548,47 @@ state: present when: ansible_os_family == "Debian" + - name: Check if Vagrant needs reinstall (Jammy+) + shell: | + # Strip epoch (e.g. "1:2.2.19" -> "2.2.19") before comparing, since the + # Ubuntu-packaged vagrant carries epoch 1 which makes apt consider it newer + # than the chacra package which has no epoch. + installed=$(dpkg-query -W -f='${Version}' vagrant 2>/dev/null | sed 's/^[0-9]*://') + dpkg --compare-versions "$installed" lt "2.4" && echo "yes" || echo "no" + register: vagrant_needs_reinstall + changed_when: false + when: ansible_os_family == "Debian" and ansible_distribution_major_version|int >= 22 + + # To ensure a clean vagrant-libvirt install, uninstall and reinstall vagrant. + - name: Purge existing Vagrant before reinstall from chacra (Jammy+) + apt: + name: vagrant + state: absent + purge: yes + when: + - ansible_os_family == "Debian" + - ansible_distribution_major_version|int >= 22 + - vagrant_needs_reinstall.stdout == "yes" + + - name: Install Vagrant from chacra (Jammy+) + apt: + name: vagrant + state: latest + update_cache: yes + when: + - ansible_os_family == "Debian" + - ansible_distribution_major_version|int >= 22 + - vagrant_needs_reinstall.stdout == "yes" + + - name: Remove stale Vagrant plugin gems after reinstall (Jammy+) + file: + path: "/home/{{ jenkins_user }}/.vagrant.d/gems" + state: absent + when: + - ansible_os_family == "Debian" + - ansible_distribution_major_version|int >= 22 + - vagrant_needs_reinstall.stdout == "yes" + - name: Add our vagrant RPM repository yum_repository: name: vagrant @@ -899,7 +940,7 @@ CONFIGURE_ARGS: 'with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib64' when: ansible_os_family == "Suse" - - name: Install the vagrant-libvirt plugin (Focal) + - name: Install the vagrant-libvirt plugin (Focal and newer) command: vagrant plugin install vagrant-libvirt become_user: "{{ jenkins_user }}" environment: