怎样在 CentOS 8 上安装 Terraform

在本教程中,我们将向您展示怎样在 CentOS 8 上安装 Terraform。对于那些不知道的人,Terraform 是 Hashicorp 的免费开源基础设施自动化工具,用于创建、构建和更改使用基础设施作为跨各种云提供商(如 AWS、Azure 云、GCP、Oracle 云等)的代码。

本文假设您至少具有 Linux 的基本知识,知道怎样使用 shell,并且最重要的是,您在自己的 VPS 上托管您的站点。 安装非常简单,假设您在 root 帐户中运行,否则您可能需要添加 ‘sudo‘ 到获得 root 权限的命令。 我将向您展示在 CentOS 8 上逐步安装 Terraform。

在 CentOS 8 上安装 Terraform

步骤 1. 首先,确保所有软件包都是最新的。

sudo dnf update

步骤 2. 在 CentOS 8 上安装 Terraform。

运行以下命令以从以下位置下载最新的 terraform 设置 Terraform 官方网站

wget https://releases.hashicorp.com/terraform/1.0.0/terraform_1.0.0_linux_amd64.zip
sudo unzip terraform_1.0.0_linux_amd64.zip

接下来,将提取的设置移动到 /usr/local/bin 目录:

sudo mv terraform /usr/local/bin/

现在可以通过运行一个简单的 terraform version 命令来验证安装:

terraform -v

成功安装后,让我们检查 terraform 命令:

terraform

输出:

terraform
Usage: terraform [-version] [-help] [args]

The available commands for execution are listed below.
The most common, useful commands are shown first, followed by
less common or more advanced commands. If you're just getting
started with Terraform, stick with the common commands. For the
other commands, please read the help and docs before usage.

Common commands:
    apply              Builds or changes infrastructure
    console            Interactive console for Terraform interpolations
    destroy            Destroy Terraform-managed infrastructure
    env                Workspace management
    fmt                Rewrites config files to canonical format
    get                Download and install modules for the configuration
    graph              Create a visual graph of Terraform resources
    import             Import existing infrastructure into Terraform
    init               Initialize a Terraform working directory
    login              Obtain and save credentials for a remote host
    logout             Remove locally-stored credentials for a remote host
    output             Read an output from a state file
    plan               Generate and show an execution plan
    providers          Prints a tree of the providers used in the configuration
    refresh            Update local state file against real resources
    show               Inspect Terraform state or plan
    taint              Manually mark a resource for recreation
    untaint            Manually unmark a resource as tainted
    validate           Validates the Terraform files
    version            Prints the Terraform version
    workspace          Workspace management


All other commands:
    0.12upgrade        Rewrites pre-0.12 module source code for v0.12
    debug              Debug output management (experimental)
    force-unlock       Manually unlock the terraform state
    push               Obsolete command for Terraform Enterprise legacy (v1)
    state              Advanced state management

恭喜! 您已成功安装 Terraform。 感谢您使用本教程在 CentOS 8 系统上安装 Terraform。 如需更多帮助或有用信息,我们建议您查看 Terraform 官方网站.

相关阅读:

Posted in: LinuxTags: