mirror of
https://github.com/khuedoan/homelab.git
synced 2024-12-23 01:14:38 +07:00
refactor: inject Terraform secrets with Terraform
Instead of Ansible
This commit is contained in:
parent
f4b63c018f
commit
479016d737
@ -4,7 +4,7 @@
|
|||||||
KUBECONFIG = ../metal/kubeconfig.yaml
|
KUBECONFIG = ../metal/kubeconfig.yaml
|
||||||
KUBE_CONFIG_PATH = $(KUBECONFIG)
|
KUBE_CONFIG_PATH = $(KUBECONFIG)
|
||||||
|
|
||||||
default: apply terraform-secrets
|
default: apply
|
||||||
|
|
||||||
~/.terraform.d/credentials.tfrc.json:
|
~/.terraform.d/credentials.tfrc.json:
|
||||||
terraform login
|
terraform login
|
||||||
@ -24,6 +24,3 @@ plan: .terraform.lock.hcl
|
|||||||
|
|
||||||
apply: .terraform.lock.hcl namespaces
|
apply: .terraform.lock.hcl namespaces
|
||||||
terraform apply
|
terraform apply
|
||||||
|
|
||||||
terraform-secrets:
|
|
||||||
ansible-playbook terraform-secrets.yml
|
|
||||||
|
11
external/tekton.tf
Normal file
11
external/tekton.tf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
resource "kubernetes_secret" "terraform_secrets" {
|
||||||
|
metadata {
|
||||||
|
name = "terraform-secrets"
|
||||||
|
namespace = "tekton-pipelines"
|
||||||
|
}
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"credentials.tfrc.json" = file("~/.terraform.d/credentials.tfrc.json")
|
||||||
|
"terraform.tfvars" = file("${path.root}/terraform.tfvars")
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
# pip install kuberentes
|
|
||||||
- hosts: localhost
|
|
||||||
tasks:
|
|
||||||
- name: Inject Terraform secrets to Tekton namespace
|
|
||||||
kubernetes.core.k8s:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Secret
|
|
||||||
type: Opaque
|
|
||||||
metadata:
|
|
||||||
name: terraform-secrets
|
|
||||||
namespace: tekton-pipelines
|
|
||||||
data:
|
|
||||||
credentials.tfrc.json: "{{ lookup('file', '~/.terraform.d/credentials.tfrc.json') | b64encode }}"
|
|
||||||
terraform.tfvars: "{{ lookup('file', './terraform.tfvars') | b64encode }}"
|
|
Loading…
Reference in New Issue
Block a user