Diving into DevOps - Vagrancy

Ahh yes, the everything-as-code infrastructure dream. I have been familiar with the concepts for a long time, and know the names and functions of many tools. I can create infrastructure on AWS or Azure, I can grab magic ephemeral servers from Docker, etc. I have not had any opportunity to use any of this in a professional environment. The places where I have worked are very slow to adopt new methodologies and technologies. This has posed a bit of an issue for me, because I typically learn things on the job. I like the immediate and direct application of skill to keep the world from burning down.

So, I am playing with things from a book. DevOps for The Desperate by Bradley Smith, published by the fantastic No Starch Press. The book takes you through examples with Vagrant, Ansible, Docker, and Kubernetes. It’ s a bit of a crash course.

I ran into some challenges almost immediately. The examples are written primarily from the perspective of controlling VirtualBox with Vagrant. I am using an M1 based MacBook Air, which VirtualBox does not support. The book provides examples on how to use different providers with Vagrant, cool, I’m not totally dead in the water.

1
vagrant plugin install vagrant-parallels 

This command installs the plugin which adds Parallels as a provider for Vagrant. The catch is that only Parallels Pro supports being remotely controlled. I do not currently have Parallels Pro, but I do have a Proxmox server.

1
vagrant plugin install vagrant-proxmox

This is the point I learned of Ruby dependency hell.

The original GitHub repo for vagrant-proxmox (which contains the version which is on RubyGems) appears to be abandoned. It has out-of-date dependencies which Ruby’s package manager was unable to resolve. Fortunately someone else forked this repo and have kept the dependencies more up-to-date. So all I had to do was build the gem and install.

Right…

Right?

Well, no.

First I learned the version of Ruby that Apple ships with macOS is an outdated version packaged in a Universal Binary. This post explains everything. I was getting errors from the FFI library as described. I decided to deal with this by installing the latest version of Ruby from Brew

1
brew install ruby

And then update my PATH as described in the warnings from Brew so that my terminal grabs the right Ruby

1
echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc

So now I have the latest arm64 Ruby and it’s time to build that gem from the rakefile…

1
rake build

Which tells me…

1
2
3
“Could not find rake-10.5.0 in any of the sources

Run `bundle install` to install missing gems.”

Okay, great.

1
bundle install

Which tells me…

1
“minitest-5.14.0 requires ruby version ~> 2.2, which is incompatible with the current version, ruby 3.1.2p20”

I found a suggestion to delete Gemfile.lock, so I did and ran bundle install again.

1
2
3
4
5
6
7
8
9
“Bundler found conflicting requirements for the Ruby version:

  In Gemfile:

    Ruby

    vagrant (= 2.2.4) was resolved to 2.2.4, which depends on

      Ruby (~> 2.2, < 2.7)”

Okay, my installed version of Vagrant is 2.3.1 so maybe I just need to update the gemfile and the vagrant-proxmox.gemspec.

Success! Now to try rake build again

1
2
3
“rake aborted!

Gem::LoadError: You have already activated rake 13.0.6, but your Gemfile requires rake 10.5.0. Prepending `bundle exec` to your command may solve this.”

I updated the rake dependency in vagrant-proxmox.gemspec and it worked! I now have a gemfile!

Lets install it!

1
vagrant plugin install ./vagrant-proxmox-0.3.0.gem

Oh no I am going to implode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
“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:

conflicting dependencies activesupport (~> 5.0) and activesupport (= 7.0.4)

  Activated activesupport-7.0.4

  which does not match conflicting dependency (~> 5.0)

  Conflicting dependency chains:

    activesupport (= 7.0.4), 7.0.4 activated

  versus:

    vagrant-proxmox (= 0.3.0), 0.3.0 activated, depends on

    activesupport (~> 5.0)

  Gems matching activesupport (~> 5.0):

    activesupport-5.2.8.1”

Yet again I updated the dependency in vagrant-proxmox.gemspec, then run bundle update, then rake build. And success!! I got the plugin to install!!

So this is my first crash course into dealing with Vagrant. From here I should be able to whip up a vagrant file to control my Proxmox server instead of VirtualBox or Parallels. I will write about this later.

My fork of vagrant-proxmox lives here: https://github.com/mikeOSX/vagrant-proxmox

References:

https://stackoverflow.com/questions/17028132/vagrant-install-plugin-from-github

https://www.ruby-lang.org/en/documentation/installation/#homebrew

https://github.com/lehn-etracker/vagrant-proxmox

https://betterprogramming.pub/ruby-on-apple-silicon-m1-macs-fb159849b2f5