From 5a93bacc088d3baec3aec269f5b03be34146d0cc Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 24 Feb 2023 08:56:51 +0800 Subject: [PATCH] translated --- ... Use Terraform to manage an OpenStack cluster.md | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) rename {sources => translated}/tech/20230131.1 ⭐️⭐️ Use Terraform to manage an OpenStack cluster.md (64%) diff --git a/sources/tech/20230131.1 ⭐️⭐️ Use Terraform to manage an OpenStack cluster.md b/translated/tech/20230131.1 ⭐️⭐️ Use Terraform to manage an OpenStack cluster.md similarity index 64% rename from sources/tech/20230131.1 ⭐️⭐️ Use Terraform to manage an OpenStack cluster.md rename to translated/tech/20230131.1 ⭐️⭐️ Use Terraform to manage an OpenStack cluster.md index ac41ff27eb..c7eadd2d3f 100644 --- a/sources/tech/20230131.1 ⭐️⭐️ Use Terraform to manage an OpenStack cluster.md +++ b/translated/tech/20230131.1 ⭐️⭐️ Use Terraform to manage an OpenStack cluster.md @@ -7,55 +7,55 @@ [#]: publisher: " " [#]: url: " " -Use Terraform to manage an OpenStack cluster +使用 Terraform 来管理 OpenStack 集群 ====== -After having an OpenStack production and home lab for a while, I can definitively say that provisioning a workload and managing it from an Admin and Tenant perspective is important. +在拥有一个 OpenStack 生产和家庭实验室一段时间后,我可以肯定地说,从管理员和租户的角度配置工作负载和管理它是很重要的。 -Terraform is an open source Infrastructure-as-Code (IaC) software tool used for provisioning networks, servers, cloud platforms, and more. Terraform is a declarative language that can act as a blueprint of the infrastructure you're working on. You can manage it with Git, and it has a strong [GitOps][1] use case. +Terraform 是一个开源的基础设施即代码(IaC)软件工具,用于配置网络、服务器、云平台等。Terraform 是一种声明性语言,可以作为你正在进行的基础设施的蓝图。你可以用 Git 来管理它,它有一个强大的 [GitOps][1] 使用场景。 -This article covers the basics of managing an OpenStack cluster using Terraform. I recreate the OpenStack Demo project using Terraform. +本文介绍了使用 Terraform 管理 OpenStack 集群的基础知识。我使用 Terraform 重新创建了 OpenStack 演示项目。 -### Install Terraform +### 安装 Terraform -I use CentOS as a jump host, where I run Terraform. Based on the official documentation, the first step is to add the Hashicorp repository: +我使用 CentOS 作为跳板机运行 Terraform。根据官方文档,第一步是添加 Hashicorp 仓库: ``` $ sudo dnf config-manager \ --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo ``` -Next, install Terraform: +接下来,安装 Terraform: ``` $ sudo dnf install terraform -y ``` -Verify the installation: +验证安装: ``` $ terraform –version ``` -If you see a version number in return, you have installed Terraform. +如果你看到返回的版本号,那么你已经安装了 Terraform。 -### Create a Terraform script for the OpenStack provider +### 为 OpenStack provider 创建一个 Terraform 脚本 -In Terraform, you need a provider. A provider is a converter that Terraform calls to convert your `.tf` into API calls to the platform you are orchestrating. +在 Terraform 中,你需要一个 provider。provider 是一个转换器,Terraform 调用它将你的 `.tf` 转换为对你正在协调的平台的 API 调用。 -There are three types of providers: Official, Partner, and Community: +有三种类型的 provider:方、合作伙伴和社区: -- Official providers are Hashicorp maintained. -- Partner providers are maintained by technology companies that partner with Hashicorp. -- Community providers are maintained by open source community members. +- 官方 provider 由 Hashicorp 维护。 +- 合作伙伴 provider 由与 Hashicorp 合作的技术公司维护。 +- 社区 provider 是由开源社区成员维护的。 -There is a good Community provider for OpenStack in this [link][2]. To use this provider, create a `.tf` file and call it `main.tf`. +在这个[链接][2]中有一个很好的 OpenStack 的社区 provider。要使用这个 provider,请创建一个 `.tf` 文件,并命名为 `main.tf`。 ``` $ vi main.tf ``` -Add the following content to `main.tf`: +在 `main.tf` 中添加以下内容: ``` terraform { @@ -77,15 +77,15 @@ provider "openstack" { } ``` -You need to change the **OS_USERNAME**, **OS_TENANT**, **OS_PASSWORD**, **OS_AUTH_URL**, and **OS_REGION** variables for it to work. +你需要修改 **OS_USERNAME**、**OS_TENANT**、**OS_PASSWORD**、**OS_AUTH_URL** 和 **OS_REGION** 变量才能工作。 -### Create an Admin Terraform file +### 创建一个 Terraform 管理文件 -OpenStack Admin files focus on provisioning external networks, routers, users, images, tenant profiles, and quotas. +OpenStack 管理文件的重点是配置外部网络、路由、用户、镜像、租户配置文件和配额。 -This example provisions flavors, a router connected to an external network, a test image, a tenant profile, and a user. +此示例提供风格,连接到外部网络的路由、测试镜像、租户配置文件和用户。 -First, create an `AdminTF` directory for the provisioning resources: +首先,为配置资源创建一个 `AdminTF` 目录: ``` $ mkdir AdminTF @@ -93,7 +93,7 @@ $ mkdir AdminTF $ cd AdminTF ``` -In the `main.tf`, add the following: +在 `main.tf` 中,添加以下内容: ``` terraform { @@ -200,20 +200,20 @@ resource "openstack_identity_user_v3" "demo-user" { } ``` -### Create a Tenant Terraform file +### 创建一个租户 Terraform 文件 -As a Tenant, you usually create VMs. You also create network and security groups for the VMs. +作为一个租户,你通常会创建虚拟机。你还为这些虚拟机创建网络和安全组。 -This example uses the user created above by the Admin file. +这个例子使用上面由 Admin 文件创建的用户。 -First, create a `TenantTF` directory for Tenant-related provisioning: +首先,创建一个 `TenantTF` 目录,用于与租户相关的配置: ``` $ mkdir TenantTF $ cd TenantTF ``` -In the `main.tf`, add the following: +在 `main.tf` 中,添加以下内容: ``` terraform { @@ -273,11 +273,11 @@ resource "openstack_compute_instance_v2" "demo-instance" { } ``` -### Initialize your Terraform +### 初始化你的 Terraform -After creating the Terraform files, you need to initialize Terraform. +创建 Terraform 文件后,你需要初始化 Terraform。 -For Admin: +对于管理员: ``` $ cd AdminTF @@ -287,7 +287,7 @@ $ terraform init $ terraform fmt ``` -For Tenants: +对于租户: ``` $ cd TenantTF @@ -297,16 +297,16 @@ $ terraform init $ terraform fmt ``` -Command explanation: +命令解释: -- `terraform init` downloads the provider from the registry to use in provisioning this project. -- `terraform fmt` formats the files for use in repositories. +- `terraform init` 从镜像源下载 provider 用于配置此项目。 +- `terraform fmt` 格式化文件,以便在仓库中使用。 -### Create a Terraform plan +### 创建一个 Terraform 计划 -Next, create a plan for you to see what resources will be created. +接下来,为你创建一个计划,看看将创建哪些资源。 -For Admin: +对于管理员: ``` $ cd AdminTF @@ -316,7 +316,7 @@ $ terraform validate $ terraform plan ``` -For Tenants: +对于租户: ``` $ cd TenantTF @@ -326,16 +326,16 @@ $ terraform validate $ terraform plan ``` -Command explanation: +命令解释: -- `terraform validate` validates whether the `.tf` syntax is correct. -- `terraform plan` creates a plan file in the cache where all managed resources can be tracked in creation and destroy. +- `terraform validate` 验证 `.tf` 语法是否正确。 +- `terraform plan` 在缓存中创建一个计划文件,所有管理的资源在创建和销毁时都可以被跟踪。 -### Apply your first TF +### 应用你的第一个 TF -To deploy the resources, use the `terraform apply` command. This command applies all resource states in the plan file. +要部署资源,使用 `terraform apply` 命令。该命令应用计划文件中的所有资源状态。 -For Admin: +对于管理员: ``` $ cd AdminTF @@ -343,7 +343,7 @@ $ cd AdminTF $ terraform apply ``` -For Tenants: +对于租户: ``` $ cd TenantTF @@ -351,9 +351,9 @@ $ cd TenantTF $ terraform apply ``` -### Next steps +### 接下来的步骤 -Previously, I wrote an [article][3] on deploying a minimal OpenStack cluster on a Raspberry Pi. You can discover how to have more detailed [Terraform and Ansible][4] configurations and implement some CI/CD with GitLab. +之前,我写了一篇关于在树莓派上部署最小 OpenStack 集群的[文章][3]。你可以找到更详细的 [Terraform 和 Ansible][4] 配置,并通过 GitLab 实现一些 CI/CD。 -------------------------------------------------------------------------------- @@ -361,7 +361,7 @@ via: https://opensource.com/article/23/1/terraform-manage-openstack-cluster 作者:[AJ Canlas][a] 选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) +译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出