mirror of
https://github.com/khuedoan/homelab.git
synced 2025-07-04 15:27:52 +07:00
Generate LXD tfvars instead of environment variable
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,5 +4,7 @@ metal/secrets/
|
||||
|
||||
*.log
|
||||
.terraform*
|
||||
terraform.tfvars
|
||||
kube_config.yaml
|
||||
private.pem
|
||||
terraform.tfstate*
|
||||
|
@ -21,6 +21,14 @@ terraform {
|
||||
provider "lxd" {
|
||||
generate_client_certificates = true
|
||||
accept_remote_certificate = true
|
||||
|
||||
lxd_remote {
|
||||
name = "homelab"
|
||||
scheme = "https"
|
||||
address = var.lxd_address
|
||||
password = var.lxd_password
|
||||
default = true
|
||||
}
|
||||
}
|
||||
|
||||
provider "rke" {
|
||||
|
@ -0,0 +1,7 @@
|
||||
variable "lxd_address" {
|
||||
description = "LXD cluster address, should be generated automatically from metal"
|
||||
}
|
||||
|
||||
variable "lxd_password" {
|
||||
description = "Password to connect to LXD cluster, should be generated automatically from metal"
|
||||
}
|
||||
|
@ -35,18 +35,19 @@
|
||||
creates: /var/snap/lxd/common/lxd/server.crt
|
||||
when: inventory_hostname != groups['metal'][0]
|
||||
|
||||
# TODO optimize: use template for tfvars
|
||||
- name: Add LXD server to environment variables
|
||||
lineinfile:
|
||||
path: "{{ playbook_dir }}/secrets/env"
|
||||
line: "LXD_ADDR={{ hostvars[groups['metal'][0]]['ansible_host'] }}"
|
||||
path: "{{ playbook_dir }}/../infra/platform/terraform.tfvars"
|
||||
line: "lxd_address = \"{{ hostvars[groups['metal'][0]]['ansible_host'] }}\""
|
||||
create: yes
|
||||
delegate_to: localhost
|
||||
run_once: yes
|
||||
|
||||
- name: Add LXD password to environment variables
|
||||
lineinfile:
|
||||
path: "{{ playbook_dir }}/secrets/env"
|
||||
line: "LXD_PASSWORD={{ lxd_password }}"
|
||||
path: "{{ playbook_dir }}/../infra/platform/terraform.tfvars"
|
||||
line: "lxd_password = \"{{ lxd_password }}\""
|
||||
create: yes
|
||||
delegate_to: localhost
|
||||
run_once: yes
|
||||
|
Reference in New Issue
Block a user