mirror of
https://github.com/khuedoan/homelab.git
synced 2025-02-06 17:18:51 +07:00
Get node config from Ansible inventory
This commit is contained in:
parent
35b8f9315e
commit
bf8ea27bc0
@ -1,35 +1,41 @@
|
|||||||
|
locals {
|
||||||
|
hosts = yamldecode(file("../metal/hosts.yml"))
|
||||||
|
user = local.hosts.metal.vars.ansible_user
|
||||||
|
ssh_key = file(local.hosts.metal.vars.ansible_ssh_private_key_file)
|
||||||
|
}
|
||||||
|
|
||||||
resource "rke_cluster" "cluster" {
|
resource "rke_cluster" "cluster" {
|
||||||
dynamic "nodes" {
|
dynamic "nodes" {
|
||||||
for_each = [
|
for_each = [
|
||||||
"192.168.1.110",
|
local.hosts.metal.hosts.metal0.ansible_host,
|
||||||
"192.168.1.111",
|
local.hosts.metal.hosts.metal1.ansible_host,
|
||||||
"192.168.1.112"
|
local.hosts.metal.hosts.metal2.ansible_host
|
||||||
]
|
]
|
||||||
|
|
||||||
content {
|
content {
|
||||||
address = nodes.value
|
address = nodes.value
|
||||||
user = "root"
|
user = local.user
|
||||||
role = [
|
role = [
|
||||||
"controlplane",
|
"controlplane",
|
||||||
"etcd",
|
"etcd",
|
||||||
"worker"
|
"worker"
|
||||||
]
|
]
|
||||||
ssh_key = file("~/.ssh/id_ed25519")
|
ssh_key = local.ssh_key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic "nodes" {
|
dynamic "nodes" {
|
||||||
for_each = [
|
for_each = [
|
||||||
"192.168.1.113"
|
local.hosts.metal.hosts.metal3.ansible_host
|
||||||
]
|
]
|
||||||
|
|
||||||
content {
|
content {
|
||||||
address = nodes.value
|
address = nodes.value
|
||||||
user = "root"
|
user = local.user
|
||||||
role = [
|
role = [
|
||||||
"worker"
|
"worker"
|
||||||
]
|
]
|
||||||
ssh_key = file("~/.ssh/id_ed25519")
|
ssh_key = local.ssh_key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ terraform {
|
|||||||
endpoints = [
|
endpoints = [
|
||||||
"192.168.1.110:23799"
|
"192.168.1.110:23799"
|
||||||
]
|
]
|
||||||
lock = true
|
lock = true
|
||||||
}
|
}
|
||||||
|
|
||||||
required_providers {
|
required_providers {
|
||||||
|
Loading…
Reference in New Issue
Block a user