使用terraform管理Proxmox VE资源

简介: 使用terraform管理Proxmox VE资源 , Using terraform to manage Proxmox VE resources

terraform-proxmox

使用terraform管理Proxmox VE资源
Using terraform to manage proxmox resources

env:
Proxmox VE v6.1
Terraform v0.11.14
provider.proxmox v0.1.0

By Elvin ,2020-8-23, http://blog.elvin.vip
git source https://gitee.com/alivv/terraform-proxmox.git


install terraform v0.11.14
wget http://files.elvin.vip/cli/terraform_0.11.14_linux_amd64.zip
unzip -oq terraform_0.11.14_linux_amd64.zip -d /usr/local/bin/
rm -f terraform_0.11.14_linux_amd64.zip
install terraform-provider-proxmox v0.1.0
wget http://files.elvin.vip/cli/terraform-provider-proxmox_0.1.0_linux_amd64.tar.gz
mkdir -p ~/.terraform.d/plugins
tar -zxf terraform-provider-proxmox_0.1.0_linux_amd64.tar.gz -C ~/.terraform.d/plugins/
rm -f    terraform-provider-proxmox_0.1.0_linux_amd64.tar.gz
clone demo
git clone https://gitee.com/alivv/terraform-proxmox.git /opt/
test
cd  /opt/terraform-proxmox/test

#config pm_api_url,pm_password,clone,storage ...
#vim vm.tf 

#test
terraform version
terraform init
terraform plan

#创建VM, 从模板ubuntu克隆vm
#Create VM, Cloning VM from template Ubuntu

terraform apply

#删除VM, Delete VM
terraform destroy
Terraform template
#使用terraform模板,批量创建VM
#Create VM in batch using terraform template

cd /opt/terraform-proxmox/vm

#mv list
cat > vm.list.txt << EOF
# name,count,cpu,ram,disk,vid,os(default ubuntu),notes(Optional)

vm-ubuntu,2,2,4,20,161,ubuntu
vm-centos,2,4,8,20,163,centos,centos for test
EOF

#make vm.tf and outputs.tf from vm.list.txt
./make.vm.tf.sh

#run check
terraform init
terraform plan

#Create VM
terraform apply
Run the demo results
# terraform version

Terraform v0.11.14
+ provider.proxmox v0.1.0

# terraform plan

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + module.vm-centos.proxmox_vm_qemu.cloudinit-test[0]
      id:                           <computed>
      agent:                        "1"
      balloon:                      "0"
      bios:                         "seabios"
      boot:                         "cdn"
      clone:                        "centos"
      clone_wait:                   "15"
      cores:                        "4"
      cpu:                          "host"
      desc:                         "centos for test"
      disk.#:                       "1"
      disk.1057333298.backup:       "false"
      disk.1057333298.cache:        "none"
      disk.1057333298.discard:      "on"
      disk.1057333298.format:       "qcow2"
      disk.1057333298.id:           "0"
      disk.1057333298.iothread:     "true"
      disk.1057333298.mbps:         "0"
      disk.1057333298.mbps_rd:      "0"
      disk.1057333298.mbps_rd_max:  "0"
      disk.1057333298.mbps_wr:      "0"
      disk.1057333298.mbps_wr_max:  "0"
      disk.1057333298.replicate:    "false"
      disk.1057333298.size:         "20G"
      disk.1057333298.ssd:          ""
      disk.1057333298.storage:      "data"
      disk.1057333298.storage_type: "dir"
      disk.1057333298.type:         "scsi"
      force_create:                 "false"
      full_clone:                   "true"
      hotplug:                      "network,disk,usb"
      ipconfig0:                    "ip=192.168.21.163/24,gw=192.168.21.1"
      kvm:                          "true"
      memory:                       "8192"
      name:                         "vm-centos-1"
      numa:                         "false"
      onboot:                       "true"
      os_type:                      "cloud-init"
      preprovision:                 "true"
      sockets:                      "1"
      ssh_host:                     <computed>
      ssh_port:                     <computed>
      target_node:                  "n11"
      vcpus:                        "0"
      vlan:                         "-1"
      vmid:                         "163"

  + module.vm-centos.proxmox_vm_qemu.cloudinit-test[1]
...

provider.proxmox source
https://github.com/Telmate/terraform-provider-proxmox/

目录
相关文章
|
4月前
|
Kubernetes API 数据库
Crossplane - 比 Terraform 更先进的云基础架构管理平台?
Crossplane - 比 Terraform 更先进的云基础架构管理平台?
|
27天前
|
存储 Linux 数据中心
【Azure 环境】在Windows系统中 使用Terraform创建中国区Azure资源步骤(入门级)
【Azure 环境】在Windows系统中 使用Terraform创建中国区Azure资源步骤(入门级)
|
4月前
|
消息中间件 Kubernetes Kafka
Terraform阿里云创建资源1分钟创建集群一键发布应用Terraform 创建 Kubernetes 集群
Terraform阿里云创建资源1分钟创建集群一键发布应用Terraform 创建 Kubernetes 集群
101 0
|
4月前
|
JSON 数据中心 数据格式
Terraform 系列 - 批量创建资源时如何根据某个字段判断是否创建
Terraform 系列 - 批量创建资源时如何根据某个字段判断是否创建
|
9月前
|
存储 运维 数据中心
Terraform的自动化管理
Terraform的自动化管理
56 0
|
存储 Kubernetes Linux
Terraform管理Kubernetes的初体验
Terraform管理Kubernetes的初体验
250 0
|
数据中心
《06基于Terraform的自动化管理云上资源实践》电子版地址
06基于Terraform的自动化管理云上资源实践
88 0
《06基于Terraform的自动化管理云上资源实践》电子版地址
|
API 数据中心 容器
Terraform 自动化执行云资源访问授权
Terraform 自动化执行云资源访问授权,解决云产品初始化需要手工点击授权问题。
517 0
Terraform 自动化执行云资源访问授权
|
Linux 数据中心 对象存储
【OSS】使用Terraform管理OSS
本文介绍Terraform的安装和配置详情,以及如何使用Terraform来管理OSS。
343 0
【OSS】使用Terraform管理OSS
|
弹性计算 关系型数据库 数据中心
资源编排ROS之自定制资源(多云部署Terraform篇)
资源编排服务(Resource Orchestration Service, 简称ROS)是阿里云提供的一项简化云计算资源管理的服务。您可以遵循ROS定义的模板规范编写资源栈模板,在模板中定义所需的云计算资源(例如ECS实例、RDS数据库实例)、资源间的依赖关系等。
1913 0
资源编排ROS之自定制资源(多云部署Terraform篇)

推荐镜像

更多