일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- kolla
- archlinux
- terraform
- libvirt
- ceph
- k8s
- OpenStack
- Kubeflow
- nfs-provisioner
- Octavia
- Ansible
- yum
- repository
- Docker
- grafana-loki
- ubuntu
- cloud-init
- cephadm
- kolla-ansible
- pacman
- Linux
- i3
- port open
- ceph-ansible
- Kubernetes
- HTML
- golang
- KVM
- awx
- Arch
Archives
- Today
- Total
YJWANG
[Terraform] OpenStack Provider (v 0.14.x) 본문
Terraform provider OpenStack
refer to :
- https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest
- https://github.com/terraform-provider-openstack/terraform-provider-openstack
- https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs
Install terraform
Download
root@yjwang0-stack-11:~/terraform# wget https://releases.hashicorp.com/terraform/0.14.7/terraform_0.14.7_linux_amd64.zip
Unzip
root@yjwang0-stack-11:~/terraform# unzip terraform_0.14.7_linux_amd64.zip
Archive: terraform_0.14.7_linux_amd64.zip
inflating: terraform
move to /usr/local/bin
root@yjwang0-stack-11:~/terraform# mv terraform /usr/local/bin/
confirm
root@yjwang0-stack-11:~/terraform# terraform --help
Usage: terraform [global options] <subcommand> [args]
The available commands for execution are listed below.
...
Test Openstack provider
Write .tf
file
This file will create single instance
You can check your admin-openrc file for provider options
admin_pass를 지정했으나 ubuntu 2004에서는 반영되지 않았음.
root@yjwang0-stack-11:~/terraform# cat test.tf
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.35.0"
}
}
}
provider "openstack" {
user_name = "admin"
tenant_name = "admin"
password = "testtest"
auth_url = "http://10.99.99.190:35357/v3"
region = "RegionOne"
}
resource "openstack_compute_instance_v2" "test-instance" {
name = "test1-u2004"
image_name = "ubuntu-2004.qcow2"
flavor_name = "2-4096-20G"
key_pair = "host-root-key"
security_groups = ["default"]
admin_pass = "testtest"
network {
name = "provider"
}
}
Run Scripts
root@yjwang0-stack-11:~/terraform# terraform init
root@yjwang0-stack-11:~/terraform# terraform plan
root@yjwang0-stack-11:~/terraform# terraform apply
...
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
...
Confirm
root@yjwang0-stack-11:~/terraform# openstack server list
+--------------------------------------+-------------+--------+-----------------------+--------------------------+------------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+-------------+--------+-----------------------+--------------------------+------------+
| 3c1c93b0-2ab3-4cb7-9e59-07f591b2ace1 | test1-u2004 | ACTIVE | provider=10.99.99.180 | ubuntu-2004.qcow2 | 2-4096-20G |
root@yjwang0-stack-11:~/terraform# ssh ubuntu@10.99.99.180
Delete Resources
root@yjwang0-stack-11:~/terraform# terraform destroy
Confirm
root@yjwang0-stack-11:~/terraform# openstack server list
반응형