Working module as per https://www.linode.com/docs/guides/create-terraform-module/
This commit is contained in:
1 parent
32d0a09ccf
commit
bb8b6dd978
9 files changed
+107
-234
No files matched your search
@@ -1,40 +1,31 @@
|
|||||||
#import {
|
terraform {
|
||||||
# to = linode_instance.new_instance
|
required_providers {
|
||||||
# id = "69613944"
|
linode = {
|
||||||
#}
|
source = "linode/linode"
|
||||||
#
|
# version = "..."
|
||||||
#import {
|
}
|
||||||
# to = linode_vpc.new_vpc
|
}
|
||||||
# id = "136969"
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
import {
|
|
||||||
to = linode_vpc_subnet.new_vpc_subnet
|
|
||||||
id = "131727"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module "eqit-vpc-subnet" {
|
# Configure the Linode Provider
|
||||||
source = "./modules/linode/linode-vpc/"
|
provider "linode" {
|
||||||
token = "${var.token}"
|
token = var.token
|
||||||
vpc_label = "${var.vpc_label}"
|
|
||||||
subnet_label = "${var.vpc_subnet_label}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module "observability-instance" {
|
module "vps1" {
|
||||||
source = "./modules/linode/linode-instance/"
|
source = "./modules/instance"
|
||||||
label = "observability"
|
label = "vps1"
|
||||||
token = "${var.token}"
|
root_pass = var.root_pass
|
||||||
root_pass = "${var.observability_root_pass}"
|
|
||||||
vpc_subnet_id = module.eqit-vpc-subnet.linode_vpc_subnet.new_vpc_subnet.id
|
|
||||||
vpc_ipv4 = "10.0.10.2"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#module "ci-cd-instance" {
|
module "vps2" {
|
||||||
# source = "./modules/linode/linode-instance/"
|
source = "./modules/instance"
|
||||||
# label = "ci-cd"
|
label = "vps2"
|
||||||
# token = "${var.token}"
|
root_pass = var.root_pass
|
||||||
# root_pass = "${var.ci_cd_root_pass}"
|
}
|
||||||
# type = "${var.ci_cd_type}"
|
|
||||||
# vpc_subnet_id = data.linode_vpc_subnet.eqit_vpc_subnet.id
|
module "vps3" {
|
||||||
# vpc_ipv4 = "10.0.10.2/32"
|
source = "./modules/instance"
|
||||||
#}
|
label = "vps3"
|
||||||
|
root_pass = var.root_pass
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Create a Linode
|
||||||
|
resource "linode_instance" "eqit_instance" {
|
||||||
|
image = var.image
|
||||||
|
label = var.label
|
||||||
|
region = var.region
|
||||||
|
type = var.type
|
||||||
|
authorized_keys = var.authorized_keys
|
||||||
|
root_pass = var.root_pass
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
variable "image" {
|
||||||
|
description = "Image to use for Linode instance"
|
||||||
|
default = "linode/almalinux9"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "label" {
|
||||||
|
description = "The Linode's label is for display purposes only, but must be unique."
|
||||||
|
default = "default-eqit-label"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "region" {
|
||||||
|
description = "The region where your Linode will be located."
|
||||||
|
default = "us-ord"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "type" {
|
||||||
|
description = "Your Linode's plan type."
|
||||||
|
default = "g6-standard-1"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "root_pass" {
|
||||||
|
description = "Your Linode's root user's password."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "authorized_keys" {
|
||||||
|
description = "SSH Keys to use for the Linode."
|
||||||
|
type = list
|
||||||
|
default = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeRI1w3uNny7KjK2UdlAnyoGdGgtOx4isSD52u5dr4QkkdLRMj42dLjgT0MK+QehlgaH2XzFPMDz+hZQ+66YeBSm+F4km/8F9XVyUzGl0scUA1p0pqeL3FiyM3Art4Bo71zuE3PvMjyI3pGMKQ3VDWVA0XdAjjSw4G+czJTxZLLBPGvzDT07WuWM4Evl6H21Gn7PB6CKNV0vuUZwGiCsjRbghml1L2kDtTXV1B6wQsniuhQigIVo6YXhMgge/2UCcmiyeEizdfaSstrQHEyxFMvlPUJyw4a3plAuPORDyZdAFF6OA7/wP5fVWoCu/CkbMIDjPifXGQOuhQU1qUVy7r"]
|
||||||
|
}
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
linode = {
|
|
||||||
source = "linode/linode"
|
|
||||||
version = "2.26.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider linode {
|
|
||||||
token = var.token
|
|
||||||
}
|
|
||||||
|
|
||||||
data linode_instances "eqit_instances" {
|
|
||||||
filter {
|
|
||||||
name = "tags"
|
|
||||||
values = ["tofu-manage"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource linode_instance "new_instance" {
|
|
||||||
label = var.label
|
|
||||||
image = var.image
|
|
||||||
root_pass = var.root_pass
|
|
||||||
region = var.region
|
|
||||||
## Optional
|
|
||||||
type = var.type
|
|
||||||
authorized_keys = var.authorized_keys
|
|
||||||
tags = ["tofu-manage"]
|
|
||||||
|
|
||||||
interface {
|
|
||||||
purpose = "public"
|
|
||||||
}
|
|
||||||
interface {
|
|
||||||
purpose = "vpc"
|
|
||||||
subnet_id = var.vpc_subnet_id
|
|
||||||
ipv4 {
|
|
||||||
vpc = var.vpc_ipv4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
## Required Variables
|
|
||||||
##
|
|
||||||
|
|
||||||
variable "token" {
|
|
||||||
description = "The linode API Token"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "label" {
|
|
||||||
description = "The label for the linode."
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "root_pass" {
|
|
||||||
description = "The root password of the linode."
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vpc_subnet_id" {
|
|
||||||
description = "vpc subnet id"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vpc_ipv4" {
|
|
||||||
description = "ipv4 address within vpc"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
## Optional Variables
|
|
||||||
##
|
|
||||||
|
|
||||||
variable "image" {
|
|
||||||
description = "The OS image for the linode."
|
|
||||||
type = string
|
|
||||||
default = "linode/almalinux9"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "type" {
|
|
||||||
description = "The linode host type."
|
|
||||||
type = string
|
|
||||||
default = "g6-nanode-1"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "authorized_keys" {
|
|
||||||
description = "The list of public keys to be authorized for ssh login."
|
|
||||||
type = list
|
|
||||||
default = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeRI1w3uNny7KjK2UdlAnyoGdGgtOx4isSD52u5dr4QkkdLRMj42dLjgT0MK+QehlgaH2XzFPMDz+hZQ+66YeBSm+F4km/8F9XVyUzGl0scUA1p0pqeL3FiyM3Art4Bo71zuE3PvMjyI3pGMKQ3VDWVA0XdAjjSw4G+czJTxZLLBPGvzDT07WuWM4Evl6H21Gn7PB6CKNV0vuUZwGiCsjRbghml1L2kDtTXV1B6wQsniuhQigIVo6YXhMgge/2UCcmiyeEizdfaSstrQHEyxFMvlPUJyw4a3plAuPORDyZdAFF6OA7/wP5fVWoCu/CkbMIDjPifXGQOuhQU1qUVy7r m00t@miserver.lan"]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "The region where the linode will run."
|
|
||||||
type = string
|
|
||||||
default = "us-ord"
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
linode = {
|
|
||||||
source = "linode/linode"
|
|
||||||
version = "2.26.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider linode {
|
|
||||||
token = var.token
|
|
||||||
}
|
|
||||||
|
|
||||||
data linode_vpc "eqit_vpc" {
|
|
||||||
id = linode_vpc.new_vpc.id
|
|
||||||
}
|
|
||||||
|
|
||||||
resource linode_vpc "new_vpc" {
|
|
||||||
label = "${var.vpc_label}"
|
|
||||||
region = "${var.region}"
|
|
||||||
}
|
|
||||||
|
|
||||||
data linode_vpc_subnet "eqit_vpc_subnet" {
|
|
||||||
vpc_id = data.linode_vpc.eqit_vpc.id
|
|
||||||
id = linode_vpc_subnet.new_vpc_subnet.id
|
|
||||||
}
|
|
||||||
|
|
||||||
resource linode_vpc_subnet "new_vpc_subnet" {
|
|
||||||
vpc_id = data.linode_vpc.eqit_vpc.id
|
|
||||||
label = "lan"
|
|
||||||
ipv4 = "10.0.10.0/24"
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
## Required Variables
|
|
||||||
##
|
|
||||||
|
|
||||||
variable "token" {
|
|
||||||
description = "The linode API Token"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vpc_label" {
|
|
||||||
description = "The label for the VPC."
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "subnet_label" {
|
|
||||||
description = "The label for the VPC subnet."
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vpc_subnet_id" {
|
|
||||||
description = "The id for the VPC subnet."
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
## Optional Variables
|
|
||||||
##
|
|
||||||
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "The region where the linode will run."
|
|
||||||
type = string
|
|
||||||
default = "us-ord"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "description" {
|
|
||||||
|
|
||||||
description = "The description of this VPC"
|
|
||||||
type = string
|
|
||||||
default = "No description provided to tofu client"
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
linode = {
|
||||||
|
source = "linode/linode"
|
||||||
|
# version = "..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure the Linode Provider
|
||||||
|
provider "linode" {
|
||||||
|
token = var.token
|
||||||
|
}
|
||||||
|
|
||||||
|
data linode_instances "eqit_instances" {
|
||||||
|
filter {
|
||||||
|
name = "tags"
|
||||||
|
values = ["tofu-manage"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a Linode
|
||||||
|
#resource "linode_instance" "observability" {
|
||||||
|
# label = "observability"
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#}
|
||||||
+17
-35
@@ -1,47 +1,29 @@
|
|||||||
## Required Variables
|
## Required Variables
|
||||||
##
|
variable "token" {
|
||||||
|
description = " Linode API token"
|
||||||
variable "vpc_label" {
|
|
||||||
description = "The label for the vpc"
|
|
||||||
type = string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vpc_subnet_label" {
|
variable "root_pass" {
|
||||||
description = "The label for the vpc subnet"
|
description = "Your Linode's root user's password."
|
||||||
type = string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ci_cd_root_pass" {
|
|
||||||
description = "Root password for ci-cd instance"
|
|
||||||
type = string
|
|
||||||
sensitive = true
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "observability_root_pass" {
|
|
||||||
description = "Root password for observability instance"
|
|
||||||
type = string
|
|
||||||
sensitive = true
|
|
||||||
}
|
|
||||||
## Optional Variables
|
## Optional Variables
|
||||||
##
|
variable "image" {
|
||||||
|
description = "Image to use for Linode instance."
|
||||||
variable "vpc_description" {
|
default = "linode/almalinux9"
|
||||||
description = "The description for the vpc"
|
|
||||||
type = string
|
|
||||||
default = "No description provided to tofu client"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vpc_subnet_ipv4" {
|
variable "label" {
|
||||||
description = "The CIDR IPV4 subnet for the vpc"
|
description = "The Linode's label is for display purposes only, but must be unique."
|
||||||
type = string
|
default = "default-eqit-instance"
|
||||||
default = "10.0.0.0/16"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ci_cd_type" {
|
variable "region" {
|
||||||
description = "The linode instance type for ci-cd"
|
description = "The region where your Linode will be located."
|
||||||
type = string
|
default = "us-ord"
|
||||||
default = "g6-standard-2"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "token" {}
|
variable "type" {
|
||||||
variable "region" {}
|
description = "Your Linode's plan type."
|
||||||
|
default = "g6-standard-1"
|
||||||
|
}
|
||||||
Reference in new issue
Block a user