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" {
|
||||
dynamic "nodes" {
|
||||
for_each = [
|
||||
"192.168.1.110",
|
||||
"192.168.1.111",
|
||||
"192.168.1.112"
|
||||
local.hosts.metal.hosts.metal0.ansible_host,
|
||||
local.hosts.metal.hosts.metal1.ansible_host,
|
||||
local.hosts.metal.hosts.metal2.ansible_host
|
||||
]
|
||||
|
||||
content {
|
||||
address = nodes.value
|
||||
user = "root"
|
||||
user = local.user
|
||||
role = [
|
||||
"controlplane",
|
||||
"etcd",
|
||||
"worker"
|
||||
]
|
||||
ssh_key = file("~/.ssh/id_ed25519")
|
||||
ssh_key = local.ssh_key
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "nodes" {
|
||||
for_each = [
|
||||
"192.168.1.113"
|
||||
local.hosts.metal.hosts.metal3.ansible_host
|
||||
]
|
||||
|
||||
content {
|
||||
address = nodes.value
|
||||
user = "root"
|
||||
user = local.user
|
||||
role = [
|
||||
"worker"
|
||||
]
|
||||
ssh_key = file("~/.ssh/id_ed25519")
|
||||
ssh_key = local.ssh_key
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ terraform {
|
||||
endpoints = [
|
||||
"192.168.1.110:23799"
|
||||
]
|
||||
lock = true
|
||||
lock = true
|
||||
}
|
||||
|
||||
required_providers {
|
||||
|
Loading…
Reference in New Issue
Block a user