This commit is contained in:
Tomás Limpinho
2025-08-18 19:44:52 +01:00
parent efe55e5d21
commit f202e105cf
9 changed files with 89 additions and 1 deletions

View File

@ -16,3 +16,12 @@ jobs:
- name: Cloning iac repository - name: Cloning iac repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Init OpenTofu
run: tofu init
- name: Plan
run: tofu plan -out=tfplan
- name: Apply
run: tofu apply -auto-approve tfplan

0
consul.tf Normal file
View File

13
documentation/start.txt Normal file
View File

@ -0,0 +1,13 @@
https://spacelift.io/blog/opentofu-tutorial - explaining language of opentofu
https://opentofu.org/docs/intro/ - quick start and explaning who to work in team
https://opentofu.org/docs/intro/ - CICD for opentofu explained
tofu init
tofu plan --var-file=opentofu-varfile.json
yes
tofu apply --var-file=opentofu-varfile.json
yes

20
main.tf Normal file
View File

@ -0,0 +1,20 @@
terraform {
required_providers {
random = {
source = "hashicorp/random"
version = "~> 3.6"
}
vaultwarden = {
source = "ottramst/vaultwarden"
version = "0.4.4"
}
}
backend "consul" {
address = "consul-server.iac-consul.svc.cluster.local:8500" # Consul service DNS inside cluster
path = "opentofu/iac-fenix" # unique path per project
scheme = "http" # or "https" if you add TLS
lock = true # enable state locking
}
}
provider "random" {}

View File

@ -0,0 +1,2 @@
consul_server = "consul-server.iac-consul.svc.cluster.local:8500"
# token is read automatically from CONSUL_HTTP_TOKEN

View File

@ -0,0 +1,4 @@
vaultwarden_server = "https://vaultwarden.example.com"
vaultwarden_email = "admin@example.com"
vaultwarden_master_password = "SuperSecretMasterPassword"
vaultwarden_admin_token = "tokenadmin"

View File

@ -0,0 +1,5 @@
variable "consul_server" {
description = "consul server URL"
type = string
sensitive = false
}

View File

@ -0,0 +1,23 @@
variable "vaultwarden_server" {
description = "Vaultwarden server URL"
type = string
sensitive = false
}
variable "vaultwarden_email" {
description = "Vaultwarden login email"
type = string
sensitive = true
}
variable "vaultwarden_master_password" {
description = "Vaultwarden master password"
type = string
sensitive = true
}
variable "vaultwarden_admin_token" {
description = "Vaultwarden admin token"
type = string
sensitive = true
}

12
vaultwarden.tf Normal file
View File

@ -0,0 +1,12 @@
provider "vaultwarden" {
endpoint = var.vaultwarden_server
email = var.vaultwarden_email
master_password = var.vaultwarden_master_password
admin_token = var.vaultwarden_admin_token
}
resource "vaultwarden_account_register" "vaultwarden-acount-fenix" {
name = "fenix"
email = var.vaultwarden_email
password = var.vaultwarden_master_password
}