Downgrading the Upgrade… Wait… What?

The latest version, checked out from the git repository and built. Good to go!

From the post “Dipping a toe into Terraform

Oh dear. I wanted the very latest version of Terraform, rather than the older version provided by OpenSuse. Be careful what you wish for! When they said latest version, they meant it! I ended up installing the very latest version 1.6 development version. That’s fine in and of itself. It compiles, it runs… but it won’t play nicely with the KVM provider I want to use for creating virtual machines. What I need is the latest production variant. But how do I get that?

When checking out a repository from Git, it is possible to specify a particular version or branch. By going to the directory where I cloned the repository and typing this:

git checkout v1.5.2

the codebase changes. I can confirm this by compiling the code as before and then checking the version:

blackdragon:~/terraform-latest # cat version/VERSION  
1.5.2

Now I have the latest production version, I can see if it will now work with KVM

Dipping a toe into Terraform

I have been wanting to experiment with Terraform as a way to deploy virtual machines on KVM. The question is, can it be done on OpenSuse?

The quick answer – yes! The longer answer – yes, but…

So, after a fresh install of Leap 15.5 I installed and ran terraform with these results…

# zypper info terraform
Loading repository data...
  
Reading installed packages...

Information for package terraform:
----------------------------------
Repository     : SUSE:SLE-15:Update
Name           : terraform
Version        : 0.13.4-6.3.1
Arch           : x86_64
Vendor         : SUSE LLC <https://www.suse.com/>
Installed Size : 89.7 MiB
Installed      : Yes
Status         : up-to-date
Source package : terraform-0.13.4-6.3.1.src
Upstream URL   : https://www.terraform.io/
Summary        : Tool for building infrastructure safely and efficiently
Description    : 
    Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

localhost:~ # terraform -v
Terraform v0.13.4

Your version of Terraform is out of date! The latest version is 1.5.2. 

That doesn’t look encouraging… So, tear it all out and let’s see if I can install from source.

blackdragon:~ # git clone https://github.com/hashicorp/terraform.git
If 'git' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf git

So, OpenSuse out of the box does not have git. Not a problem, as the system tells us what to do…

blackdragon:~ # cnf git
                     
The program 'git' can be found in following packages:
  * git-core [ path: /usr/bin/git, repository: zypp (openSUSE-Leap-15.5-1) ]
  * git-core [ path: /usr/bin/git, repository: zypp (repo-oss) ]
  * git-core [ path: /usr/bin/git, repository: zypp (https-download.opensuse.org-e37130c1) ]

Try installing with:
    zypper install git-core

blackdragon:~ # zypper install git-core
Loading repository data...

Reading installed packages...
Resolving package dependencies...

The following 4 NEW packages are going to be installed:
  git-core git-gui gitk libsha1detectcoll1

4 new packages to install.
Overall download size: 5.4 MiB. Already cached: 0 B. After the operation, additional 28.9 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving: libsha1detectcoll1-1.0.3-2.18.x86_64 (SUSE:SLE-15:Update)                                                                                                    (1/4),  23.2 KiB    
Retrieving: libsha1detectcoll1-1.0.3-2.18.x86_64.rpm ..................................................................................................................................[done]
Retrieving: git-core-2.35.3-150300.10.27.1.x86_64 (SUSE:SLE-15:Update)                                                                                                   (2/4),   4.9 MiB    
Retrieving: git-core-2.35.3-150300.10.27.1.x86_64.rpm .....................................................................................................................[done (8.9 MiB/s)]
Retrieving: gitk-2.35.3-150300.10.27.1.x86_64 (SUSE:SLE-15:Update)                                                                                                       (3/4), 232.3 KiB    
Retrieving: gitk-2.35.3-150300.10.27.1.x86_64.rpm .........................................................................................................................[done (1.1 MiB/s)]
Retrieving: git-gui-2.35.3-150300.10.27.1.x86_64 (SUSE:SLE-15:Update)                                                                                                    (4/4), 298.6 KiB    
Retrieving: git-gui-2.35.3-150300.10.27.1.x86_64.rpm ..................................................................................................................................[done]

Checking for file conflicts: ..........................................................................................................................................................[done]
(1/4) Installing: libsha1detectcoll1-1.0.3-2.18.x86_64 ................................................................................................................................[done]
(2/4) Installing: git-core-2.35.3-150300.10.27.1.x86_64 ...............................................................................................................................[done]
(3/4) Installing: gitk-2.35.3-150300.10.27.1.x86_64 ...................................................................................................................................[done]
(4/4) Installing: git-gui-2.35.3-150300.10.27.1.x86_64 ................................................................................................................................[done]

Done! Now I can fetch the source code and compile it.

blackdragon:~ # git clone https://github.com/hashicorp/terraform.git
Cloning into 'terraform'...
remote: Enumerating objects: 277778, done.
remote: Counting objects: 100% (891/891), done.
remote: Compressing objects: 100% (480/480), done.
remote: Total 277778 (delta 475), reused 717 (delta 394), pack-reused 276887
Receiving objects: 100% (277778/277778), 292.23 MiB | 20.54 MiB/s, done.
Resolving deltas: 100% (172709/172709), done.

blackdragon:~ # cd terraform

Now, at this point I am meant to be able to compile the code using go, but it is not installed. However, the output from cnf gives lots of options, none of which appear to be the right choice. A bit of searching on the internet told me to install both the ‘go’ and ‘go-doc’ packages. This was done and I was able to run the ‘go install’ command successfully.

Once the compilation is complete, I had to copy the binary from my go/bin directory to /usr/local/bin after checking that directory is in the system path.

blackdragon:~/terraform # echo $PATH
/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin

...

blackdragon:~ # cp go/bin/terraform /usr/local/bin/
blackdragon:~ # terraform -v
Terraform v1.6.0-dev
on linux_amd64

The latest version, checked out from the git repository and built. Good to go!