- Installing OpenTofu
- .rpm-based Linux (RHEL, openSUSE, Fedora)
Installing OpenTofu on RHEL, Fedora, openSUSE, and other RPM-based distributions
Thank you to for sponsoring the OpenTofu package hosting.
OpenTofu is distributed in the .rpm package format on Packagecloud. You can install it using a convenience script or by following the step-by-step instructions below.
Installing using the convenience script
You can install OpenTofu using the convenience script with the following commands:
- Yum (RHEL/Fedora/etc.)
- Zypper (openSUSE)
curl --proto '=https' --tlsv1.2 -fsSL 'https://packages.opentofu.org/install/repositories/opentofu/tofu/script.rpm.sh?any=true' -o /tmp/tofu-repository-setup.sh
# Inspect the downloaded script at /tmp/tofu-repository-setup.sh before running
sudo bash /tmp/tofu-repository-setup.sh
rm /tmp/tofu-repository-setup.sh
sudo yum install -y tofu
curl --proto '=https' --tlsv1.2 -fsSL 'https://packages.opentofu.org/install/repositories/opentofu/tofu/script.rpm.sh?any=true' -o /tmp/tofu-repository-setup.sh
# Inspect the downloaded script at /tmp/tofu-repository-setup.sh before running
sudo bash /tmp/tofu-repository-setup.sh
rm /tmp/tofu-repository-setup.sh
sudo zypper install -y tofu
Step-by-step instructions
The following steps explain how to set up the OpenTofu RPM repositories. These instructions should work on most RPM-based Linux systems.
Adding the OpenTofu repository
- Yum (RHEL/Fedora/etc.)
- Zypper (openSUSE)
Create the
/etc/yum.repos.d/opentofu.repo
file by running the following command:cat >/etc/yum.repos.d/opentofu.repo <<EOF
[opentofu]
name=opentofu
baseurl=https://packages.opentofu.org/opentofu/tofu/rpm_any/rpm_any/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packages.opentofu.org/opentofu/tofu/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[opentofu-source]
name=opentofu-source
baseurl=https://packages.opentofu.org/opentofu/tofu/rpm_any/rpm_any/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packages.opentofu.org/opentofu/tofu/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF
Create the
/etc/zypp/repos.d/opentofu.repo
file by running the following command:cat >/etc/zypp/repos.d/opentofu.repo <<EOF
[opentofu]
name=opentofu
baseurl=https://packagecloud.io/opentofu/tofu/rpm_any/rpm_any/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/opentofu/tofu/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[opentofu-source]
name=opentofu-source
baseurl=https://packagecloud.io/opentofu/tofu/rpm_any/rpm_any/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/opentofu/tofu/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF
Installing OpenTofu
Now you install OpenTofu by running:
- Yum (RHEL/Fedora/etc)
- Zypper (openSUSE)
sudo yum install -y tofu
zypper --gpg-auto-import-keys refresh opentofu
zypper --gpg-auto-import-keys refresh opentofu-source
zypper install -y tofu