-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft: [New config] Terraform resources (#23)
* [feat/tf] added initial files for terraform * [feat/terraform] fixed variables to initial deployment * [feat/terraform] added new patch for unifi resources * [feat/terraform] added initial Vault module to Terraform * [feat/terraform] updated terraform module to include vars * [feat/terraform] updpated terraform vault-related module * [misc] fixed commands for task files * [feat/terraform] removed README terraform-docs on index * Update kustomization.yaml * [feat/terraform] added secret files to gitignore * [feat/terraform] additional cmds to tf taskfile * [feat/terraform] minor fix to vault secret creation * [feat/terraform] fixes and improvements unifi module * [feat/terraform] fix for terraform backend config * [feat/terraform] fix tf files endline * [feat/terraform] updated docs * [feat/terraform] fix endline tf file * [feat/terraform] fix endline tf file
- Loading branch information
Showing
33 changed files
with
687 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
version: '3' | ||
vars: | ||
CYAN: tput setaf 6 | ||
RED: tput setaf 1 | ||
YELLOW: tput setaf 3 | ||
GREEN: tput setaf 2 | ||
BLUE: tput setaf 1 | ||
PURPLE: tput setaf 5 | ||
BG_B: tput setab 0 | ||
BOLD: tput bold | ||
RESET: tput sgr0 | ||
CLEAR: tput reset | ||
PATH_ERROR: is not installed or correctly configured in PATH. | ||
|
||
silent: true | ||
|
||
tasks: | ||
init: | ||
dir: terraform | ||
cmds: | ||
- terraform init | ||
plan: | ||
dir: terraform | ||
cmds: | ||
- terraform plan | ||
apply: | ||
dir: terraform | ||
cmds: | ||
- terraform apply -auto-approve | ||
destroy: | ||
dir: terraform | ||
cmds: | ||
- terraform destroy -auto-approve | ||
|
||
docs: | ||
cmds: | ||
- terraform-docs markdown -c ./terraform/.terraform-docs.yaml . --output-file README.md | ||
- terraform-docs markdown -c ./terraform/.terraform-docs.yaml ./terraform/modules/vault --output-file README.md | ||
- terraform-docs markdown -c ./terraform/.terraform-docs.yaml ./terraform/modules/unifi --output-file README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
formatter: markdown | ||
|
||
sections: | ||
show: | ||
- inputs | ||
- outputs | ||
- modules | ||
|
||
output: | ||
file: README.md | ||
mode: inject | ||
template: |- | ||
<!-- BEGIN_TF_DOCS --> | ||
{{ .Content }} | ||
<!-- END_TF_DOCS --> | ||
sort: | ||
enabled: true | ||
by: name | ||
|
||
settings: | ||
anchor: false | ||
indent: 3 | ||
color: true | ||
html: true | ||
escape: true | ||
default: true | ||
required: false | ||
type: true | ||
sensitive: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Terraform | ||
|
||
### Providers | ||
|
||
> - hashicorp/vault | ||
> - paultyng/unifi | ||
--- | ||
|
||
<details> | ||
<summary> | ||
<b>Variable and resources documentation</b> | ||
</summary> | ||
|
||
--- | ||
<!-- BEGIN_TF_DOCS --> | ||
### Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| unifi | ./unifi | n/a | | ||
|
||
### Inputs | ||
|
||
| Name | Description | Type | Default | | ||
|------|-------------|------|---------| | ||
| unifi\_api\_url | <sub>Provides a connection URI to bridge Terraform with Unifi's controller. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#api_url)</sub> | `string` | `""` | | ||
| unifi\_insecure | <sub>Skip TLS verification when trying to access the API. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#allow_insecure)</sub> | `string` | `""` | | ||
| unifi\_password | <sub>Providers a password for your Unifi controller. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#password)</sub> | `string` | `""` | | ||
| unifi\_site\_name | n/a | `string` | `"main"` | | ||
| unifi\_upstream\_dns | <sub>Skip TLS verification when trying to access the API. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#allow_insecure)</sub> | `list` | <pre>[<br> "8.8.8.8",<br> "1.1.1.1"<br>]</pre> | | ||
| unifi\_username | <sub>Provides a username for your Unifi controller. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#username).</sub> | `string` | `"example"` | | ||
| vault\_github\_org | <sub>[Provide a Github organization name to authorize users inside Vault.](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/github_auth_backend#organization)</sub> | `string` | `"takeru-org"` | | ||
| vault\_password | <sub>Vault password for the main user, used for login purposes.</sub> | `string` | `""` | | ||
| vault\_path | <sub>Vault password for the main user, used for login purposes.</sub> | `string` | `""` | | ||
| vault\_userdata | <sub>Mock variable required by Vault userpass login method.</sub> | `any` | n/a | | ||
| vault\_username | <sub>Vault plaintext username to login.</sub> | `string` | `"gruber"` | | ||
|
||
### Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module "unifi" { | ||
source = "./modules/unifi" | ||
site_name = var.unifi_site_name | ||
admin_username = var.unifi_username | ||
admin_password = var.unifi_password | ||
api_url = var.unifi_api_url | ||
controller_sec = var.unifi_insecure | ||
upstream_dns = var.unifi_upstream_dns | ||
} | ||
|
||
resource "unifi_network" "vlan" { | ||
name = "main" | ||
purpose = "corporate" | ||
subnet = "192.168.1.0/24" | ||
dhcp_start = "192.168.1.6" | ||
dhcp_stop = "192.168.1.254" | ||
dhcp_enabled = true | ||
dhcp_relay_enabled = false | ||
network_group = "LAN" | ||
site = module.unifi.site_id | ||
dhcp_dns = var.unifi_upstream_dns | ||
} | ||
|
||
module "vault" { | ||
source = "./modules/vault" | ||
api_url = var.vault_api_url | ||
root_token = var.vault_token | ||
admin_username = var.vault_username | ||
admin_password = var.vault_password | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
<details> | ||
<summary> | ||
<b>Module documentation</b> | ||
</summary> | ||
|
||
--- | ||
<!-- BEGIN_TF_DOCS --> | ||
### Modules | ||
|
||
No modules. | ||
|
||
### Inputs | ||
|
||
| Name | Description | Type | Default | | ||
|------|-------------|------|---------| | ||
| admin\_password | <sub>Providers a password for your Unifi controller. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#password)</sub> | `string` | `""` | | ||
| admin\_username | <sub>Provides a username for your Unifi controller. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#username).</sub> | `string` | `"example"` | | ||
| api\_url | <sub>Provides a connection URI to bridge Terraform with Unifi's controller. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#api_url)</sub> | `string` | `""` | | ||
| controller\_sec | <sub>Skip TLS verification when trying to access the API. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#allow_insecure)</sub> | `string` | `""` | | ||
| site\_name | <sub>Defines [a name for your controller](https://registry.terraform.io/providers/paultyng/unifi/latest/docs/resources/site#name) site name.</sub> | `string` | `"main"` | | ||
| upstream\_dns | <sub>Skip TLS verification when trying to access the API. [Reference](https://registry.terraform.io/providers/paultyng/unifi/latest/docs#allow_insecure)</sub> | `list` | <pre>[<br> "8.8.8.8",<br> "1.1.1.1"<br>]</pre> | | ||
|
||
### Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| site\_id | n/a | | ||
<!-- END_TF_DOCS --> | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# locals { | ||
# userscsv = csvdecode(file("${path.module}/users.csv")) | ||
# users = { for user in local.userscsv : user.mac => user } | ||
# } | ||
|
||
resource "unifi_site" "homelab" { | ||
description = "Main site" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "unifi_network" "wan" { | ||
name = "simDigital" | ||
purpose = "wan" | ||
|
||
wan_networkgroup = "WAN" | ||
wan_type = "dhcp" | ||
site = unifi_site.homelab.name | ||
wan_dns = var.upstream_dns | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "site_id" { | ||
value = unifi_site.homelab.name | ||
} |
Oops, something went wrong.