Terraform快速编排OpenStack

Terraform介绍

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

在这里插入图片描述

Infra as code

Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

环境准备

部署一个单节点的OpenStack环境,参考这篇文档
https://docs.openstack.org/devstack/latest/guides/single-machine.html

Installation shake and bake¶

Add your user

We need to add a user to install DevStack. (if you created a user during install you can skip this step and just give the user sudo privileges below)

$ sudo useradd -s /bin/bash -d /opt/stack -m stack

Since this user will be making many changes to your system, it will need to have sudo privileges:

$ apt-get install sudo -y || yum install -y sudo
$ echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

On some systems you may need to use sudo visudo.
From here on you should use the user you created. Logout and login as that user:

$ sudo su stack && cd ~

Download DevStack

We’ll grab the latest version of DevStack via https:

$ sudo apt-get install git -y || sudo yum install -y git
$ git clone https://opendev.org/openstack/devstack
$ cd devstack
Run DevStack

Now to configure stack.sh. DevStack includes a sample in devstack/samples/local.conf. Create local.conf as shown below to do the following:

Set FLOATING_RANGE to a range not used on the local network, i.e. 192.168.1.224/27. This configures IP addresses ending in 225-254 to be used as floating IPs.
Set FIXED_RANGE to configure the internal address space used by the instances.
Set the administrative password. This password is used for the admin and demo accounts set up as OpenStack users.
Set the MySQL administrative password. The default here is a random hex string which is inconvenient if you need to look at the database directly for anything.
Set the RabbitMQ password.
Set the service password. This is used by the OpenStack services (Nova, Glance, etc) to authenticate with Keystone.
local.conf should look something like this:

[[local|localrc]]
FLOATING_RANGE=192.168.1.224/27
FIXED_RANGE=10.11.12.0/24
ADMIN_PASSWORD=supersecret
DATABASE_PASSWORD=iheartdatabases
RABBIT_PASSWORD=flopsymopsy
SERVICE_PASSWORD=iheartksl

Note: There is a sample local.conf file under the samples directory in the devstack repository.

Run DevStack:
$ ./stack.sh

Terraform安装

  1. MacOS 安装Terraform
brew install hashicorp/tap/terraform

Debian:

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform

CentOS:

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y in
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值