Skip to content

Deploy using OpenTofu #1791

@srbarrios

Description

@srbarrios

This is a copy of the card created by https://github.com/NamelessOne91 on https://github.com/SUSE/spacewalk/issues/26597

Given Terraform's license changes, switching to OpenTofu is probably the safest option to continue maintaining our tooling and test infrastructure the same without undergoing massive refactors.

I tried quickly verifying if that's possible and what would be the effort.

I just run one simple testsuite setup on Sumaform master with the latest tofu binary available for Tumbleweed.
Still breaks for all the current issues, but seems working from the tooling side.

The only needed changes were:

  • allowing using an higher Terraform version (OpenTofu starts at 1.5.something).

terraform {
required_version = ">=1.0.10"
.....

  • place the provider binary under /usr/share/terraform/plugins/registry.opentofu.org/dmacvicar/libvirt/0.8.1/linux_amd64/

2nd is to make Tofu see the system-wide installed providers RPMs.
It uses that dir (or a configured one) as cache and if the provider is not there it will search in its registry otherwise - which I guess mirrors the Terraform one.
There are other ways to handle this, but having an installation script take care of it should not be too difficult.

That's actually what Terraform does too, just with registry.terraform.io instead.
Our internally built provider RPM binary ends up there after a zypper in, we can make so that it creates also the path for OpenTofu when installed.

Also, that's really an issue due to the fact we want to use our own built binaries, not with OpenTofu itself.

Of course that will require proper testing with our setup, but it may be really a quite transparent thing for the end user.
Both terraform-provider-libvirt and sumaform may be easily turned into not caring whether they're used with Terraform or OpenTofu and we should be able to switch.

In the provider specfile

mkdir -p %{buildroot}%{_datadir}/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/${VERSION}/${PROVIDER_OS_PATH}
ln -s %{_bindir}/terraform-provider-libvirt %{buildroot}%{_datadir}/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/${VERSION}/${PROVIDER_OS_PATH}/terraform-provider-libvirt

Creating also the path for opentofu.registry.com and linking the binary in there would maybe be enough

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions