mirror of
https://github.com/khuedoan/homelab.git
synced 2025-07-04 23:40:20 +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
|
*.log
|
||||||
.terraform*
|
.terraform*
|
||||||
|
terraform.tfvars
|
||||||
kube_config.yaml
|
kube_config.yaml
|
||||||
|
private.pem
|
||||||
terraform.tfstate*
|
terraform.tfstate*
|
||||||
|
@ -21,6 +21,14 @@ terraform {
|
|||||||
provider "lxd" {
|
provider "lxd" {
|
||||||
generate_client_certificates = true
|
generate_client_certificates = true
|
||||||
accept_remote_certificate = true
|
accept_remote_certificate = true
|
||||||
|
|
||||||
|
lxd_remote {
|
||||||
|
name = "homelab"
|
||||||
|
scheme = "https"
|
||||||
|
address = var.lxd_address
|
||||||
|
password = var.lxd_password
|
||||||
|
default = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
provider "rke" {
|
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
|
creates: /var/snap/lxd/common/lxd/server.crt
|
||||||
when: inventory_hostname != groups['metal'][0]
|
when: inventory_hostname != groups['metal'][0]
|
||||||
|
|
||||||
|
# TODO optimize: use template for tfvars
|
||||||
- name: Add LXD server to environment variables
|
- name: Add LXD server to environment variables
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: "{{ playbook_dir }}/secrets/env"
|
path: "{{ playbook_dir }}/../infra/platform/terraform.tfvars"
|
||||||
line: "LXD_ADDR={{ hostvars[groups['metal'][0]]['ansible_host'] }}"
|
line: "lxd_address = \"{{ hostvars[groups['metal'][0]]['ansible_host'] }}\""
|
||||||
create: yes
|
create: yes
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: yes
|
run_once: yes
|
||||||
|
|
||||||
- name: Add LXD password to environment variables
|
- name: Add LXD password to environment variables
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: "{{ playbook_dir }}/secrets/env"
|
path: "{{ playbook_dir }}/../infra/platform/terraform.tfvars"
|
||||||
line: "LXD_PASSWORD={{ lxd_password }}"
|
line: "lxd_password = \"{{ lxd_password }}\""
|
||||||
create: yes
|
create: yes
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: yes
|
run_once: yes
|
||||||
|
Reference in New Issue
Block a user