如何在Fedora安装Terraform 32/31/30/29

时间:2020-02-23 14:33:17  来源:igfitidea点击:

本教程将在Fedora 32/31/30/29/28安装Terraform。
Terraform是一种云可靠的基础设施自动化工具,用于管理云和内部部署资源。
Terraform可以构建,更改和版本在流行的服务提供商上部署的基础架构。

使用Terraform,我们可以使用简单的声明性编程语言管理云计算,网络,负载均衡器,DNS等。
请参阅Terraform提供程序的完整列表。

在Fedora安装Terraform 32/31/30/29/28

Terraform在GitHub上作为tar包分发。
在下面下载之前检查Terraform发布页面上的最新版本。

截至本文的写作,最新版本是v0.12.26.
如下下载:

sudo dnf install wget
TER_VER=`curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | grep tag_name | cut -d: -f2 | tr -d \"\,\v | awk '{=};1'`
wget https://releases.hashicorp.com/terraform/${TER_VER}/terraform_${TER_VER}_linux_amd64.zip

一旦下载,提取存档:

$unzip terraform_${TER_VER}_linux_amd64.zip
Archive:  terraform_xxx_linux_amd64.zip
 inflating: terraform

这将在工作目录上创建一个Terraform二进制文件。
将此文件移动到目录 /usr/local/bin

sudo mv terraform /usr/local/bin/

这将使所有用户帐户可访问该工具。

$which terraform
/usr/local/bin/terraform

确认已安装的版本

$terraform -v
Terraform v0.12.26

验证该工具是否有效:

$terraform
Usage: terraform [-version] [-help] <command> [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
    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
    push               Upload this Terraform module to Atlas to run
    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:
    debug              Debug output management (experimental)
    force-unlock       Manually unlock the terraform state
    state              Advanced state management

下一步

既然我们已安装Terraform,则是使用最小的Terraform配置文件构建基础架构。