惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Forbes - Security
Forbes - Security
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
W
WeLiveSecurity
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News and Events Feed by Topic
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
PCI Perspectives
PCI Perspectives
Martin Fowler
Martin Fowler
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
WordPress大学
WordPress大学
S
Security Affairs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
SegmentFault 最新的问题
P
Privacy International News Feed
IT之家
IT之家
M
MIT News - Artificial intelligence
G
GRAHAM CLULEY
Hacker News: Ask HN
Hacker News: Ask HN
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Check Point Blog
美团技术团队
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
I
InfoQ
N
News | PayPal Newsroom
TaoSecurity Blog
TaoSecurity Blog

jobcher on 打工人日志

2023-12-21 打工人日报 2023-12-20 打工人日报 2023-12-19 打工人日报 2023-12-18 打工人日报 2023-12-17 打工人日报 2023-12-16 打工人日报 2023-12-15 打工人日报 2023-12-14 打工人日报 2023-12-13 打工人日报 2023-12-12 打工人日报 2023-12-11 打工人日报 2023-12-10 打工人日报 2023-12-09 打工人日报 2023-12-08 打工人日报 2023-12-07 打工人日报 2023-12-06 打工人日报 2023-12-05 打工人日报 2023-12-04 打工人日报 2023-12-03 打工人日报 2023-12-02 打工人日报 2023-12-01 打工人日报 2023-11-30 打工人日报 2023-11-29 打工人日报 2023-11-28 打工人日报 2023-11-27 打工人日报 2023-11-26 打工人日报 2023-11-25 打工人日报 2023-11-24 打工人日报 2023-11-23 打工人日报 2023-11-22 打工人日报 2023-11-21 打工人日报 2023-11-20 打工人日报 2023-11-19 打工人日报 2023-11-17 打工人日报 2023-11-16 打工人日报 2023-11-15 打工人日报 2023-11-14 打工人日报 2023-11-13 打工人日报 2023-11-12 打工人日报 2023-11-11 打工人日报 2023-11-10 打工人日报 2023-11-09 打工人日报 2023-11-08 打工人日报 2023-11-07 打工人日报 2023-11-06 打工人日报 2023-11-05 打工人日报 2023-11-04 打工人日报 2023-11-03 打工人日报 2023-11-02 打工人日报 2023-11-01 打工人日报 2023-10-31 打工人日报 2023-10-30 打工人日报 2023-10-29 打工人日报 2023-10-28 打工人日报 2023-10-27 打工人日报 2023-10-26 打工人日报 2023-10-25 打工人日报 2023-10-24 打工人日报 2023-10-23 打工人日报 2023-10-22 打工人日报 2023-10-21 打工人日报 2023-10-20 打工人日报 2023-10-19 打工人日报 2023-10-18 打工人日报 2023-10-17 打工人日报 2023-10-16 打工人日报 2023-10-15 打工人日报 2023-10-14 打工人日报 2023-10-13 打工人日报 2023-10-12 打工人日报 2023-10-11 打工人日报 2023-10-10 打工人日报 2023-10-09 打工人日报 2023-10-07 打工人日报 2023-10-06 打工人日报 2023-10-05 打工人日报 2023-10-04 打工人日报 2023-10-03 打工人日报 2023-10-02 打工人日报 2023-10-01 打工人日报 2023-09-30 打工人日报 2023-09-29 打工人日报 2023-09-28 打工人日报 2023-09-27 打工人日报 2023-09-26 打工人日报 2023-09-25 打工人日报 2023-09-24 打工人日报 2023-09-23 打工人日报 2023-09-22 打工人日报 2023-09-21 打工人日报 2023-09-20 打工人日报 2023-09-19 打工人日报 2023-09-18 打工人日报 2023-09-17 打工人日报 2023-09-16 打工人日报 2023-09-15 打工人日报 2023-09-14 打工人日报 2023-09-13 打工人日报 2023-09-12 打工人日报 2023-09-11 打工人日报
安装配置 Terraform
2021-12-27 · via jobcher on 打工人日志

安装配置 Terraform

安装

  1. macOS 苹果系统安装
1#安装
2brew tap hashicorp/tap
3brew install hashicorp/tap/terraform
4# 更新
5brew update
6brew upgrade hashicorp/tap/terraform
7#验证安装
8terraform -help
  1. windows 系统安装
1#安装
2choco install terraform
3#直接到这个url里下载64位系统
4https://www.terraform.io/downloads
5#验证安装
6terraform -help
  1. Linux 安装
1curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
2sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
3sudo apt-get update && sudo apt-get install terraform
4#验证安装
5terraform -help
1wget -O- https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo | sudo tee /etc/yum.repos.d/hashicorp.repo
2sudo yum install terraform -y

terrafrom 控制 proxmox 虚拟机

来源:https://github.com/Telmate/terraform-provider-proxmox

首先你要有一台 pve 主机

安装过程本篇文章就不想了,主要是要写一下关于他的配置
https://pve.proxmox.com/pve-docs/

  1. 下载
1wget https://github.com/Telmate/terraform-provider-proxmox/releases/download/v2.9.3/terraform-provider-proxmox_2.9.3_linux_amd64.zip
2unzip terraform-provider-proxmox_2.9.3_linux_amd64.zip

编写 terrafrom 程序

  1. 虚拟机 main.tf
 1terraform {
 2  required_version = ">= 0.14"
 3  required_providers {
 4    proxmox = {
 5      source  = "telmate/proxmox"
 6    }
 7  }
 8}
 9
10provider "proxmox" {
11  # 配置选项
12    pm_tls_insecure = true
13    pm_api_url = "https://localhost:8006/api2/json"
14    pm_user = "root@pam"
15    pm_password = "passwd"
16    pm_otp = ""
17}
18
19# 创建VM
20resource "proxmox_vm_qemu" "cloudinit-test" {
21    name = "terraform-test-vm"
22    desc = "A test for using terraform and cloudinit"
23
24    #节点名称必须与集群内的名称相同
25    #这可能不包括 FQDN
26    target_node = "pve"
27
28    #新虚拟机的目标资源池
29    pool = "pool0"
30
31    #从中克隆这个虚拟机的模板名称
32    clone = "node0"
33
34    #为这个虚拟机激活 QEMU 代理
35    agent = 1
36
37    os_type = "cloud-init"
38    cores = 2
39    sockets = 1
40    vcpus = 0
41    cpu = "host"
42    memory = 2048
43    scsihw = "lsi"
44
45    #设置磁盘
46    disk {
47        size = 32
48        type = "virtio"
49        storage = "local-lvm"
50        storage_type = "lvmthin"
51        iothread = 1
52        ssd = 1
53        discard = "on"
54    }
55
56    #设置网络接口并分配一个 vlan 标签:256
57    network {
58        model = "virtio"
59        bridge = "vmbr0"
60        tag = 256
61    }
62}
  1. 运行 terrafrom
1# 初始化
2terraform init
3# 查看产生的变更
4terraform plan
5# 运行
6terraform apply

配置

配置这个 terraform 我们这个需要持续更新,首先我们先配置 Azure 吧

Azure 配置

  1. 安装 azurecli
1# linux
2curl -L https://aka.ms/InstallAzureCli | bash
3apt install azure-cli
4# macOS
5brew update && brew install azure-cli
  1. 登录 azure
1# 中国区azure
2az cloud set --name AzureCloud
3az login -u <账户> -p <密码>
4
5#海外azure
6az cloud set --name AzureChinaCloud
7az login -u <账户> -p <密码>
  1. 创建 terrafrom 代码 创建 main.tf
 1# 正在使用的 Azure 提供程序源和版本
 2terraform {
 3    required_version = ">=0.12"
 4
 5    required_providers {
 6        azurerm = {
 7            source = "hashicorp/azurerm"
 8            version = "~>2.0"
 9        }
10    }
11}
12# 配置 Microsoft Azure 提供程序
13provider "azurerm" {
14  features {}
15}
16
17# 资源组前缀
18resource "random_pet" "rg-name" {
19  prefix    = var.resource_group_name_prefix
20}
21
22# 创建资源组
23resource "azurerm_resource_group" "rg" {
24  name      = random_pet.rg-name.id
25  location  = var.resource_group_location
26}

创建 variable.tf

1variable "resource_group_name_prefix" {
2  default       = "rg"
3  description   = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
4}
5
6variable "resource_group_location" {
7  default = "eastus"
8  description   = "Location of the resource group."
9}