Skip to content

Commit b0866b7

Browse files
committed
Initial commit
1 parent a88a8dd commit b0866b7

13 files changed

+292
-2
lines changed

.checkov.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
block-list-secret-scan: []
2+
compact: true
3+
directory:
4+
- .
5+
download-external-modules: false
6+
evaluate-variables: true
7+
framework:
8+
- all
9+
output:
10+
- cli
11+
quiet: true
12+
soft-fail: true
13+
summary-position: top

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# vim swap files
2+
**/*.sw[po]
3+
4+
# don't commit terraform state or lock. the repo code is the only state we care about.
5+
# the provider state cache is auto-upgraded by default to ensure compatibility with upstream cloud provider APIs
6+
**/.terraform.lock.hcl
7+
**/.terraform
8+
9+
# IDE Folders
10+
**/.vscode
11+
12+
# Mac Finder cache
13+
**/.DS_Store

.pre-commit-config.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-merge-conflict
7+
- id: check-symlinks
8+
- id: check-vcs-permalinks
9+
- id: destroyed-symlinks
10+
- id: detect-private-key
11+
- id: mixed-line-ending
12+
- id: trailing-whitespace
13+
- repo: https://github.com/antonbabenko/pre-commit-terraform
14+
rev: v1.89.1
15+
hooks:
16+
- id: terraform_validate
17+
args:
18+
- --hook-config=--retry-once-with-cleanup=true
19+
- --args=-no-color
20+
- --tf-init-args=-reconfigure
21+
- --tf-init-args=-upgrade
22+
- id: terraform_tflint
23+
args:
24+
- --args=--minimum-failure-severity=error
25+
- --args=--config=__GIT_WORKING_DIR__/.tflint.hcl
26+
- id: terraform_checkov
27+
args:
28+
- --args=--config-file __GIT_WORKING_DIR__/.checkov.yml
29+
- id: terraform_fmt
30+
args:
31+
- --args=-no-color
32+
- --args=-diff
33+
- --args=-recursive
34+
- id: terraform_docs
35+
args:
36+
- --args=--config=.terraform-docs.yml

.sops.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
creation_rules:
3+
- age: age152ek83tm4fj5u70r3fecytn4kg7c5xca24erjchxexx4pfqg6das7q763l

.terraform-docs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
formatter: "markdown"
2+
3+
output:
4+
file: "README.md"
5+
mode: replace
6+
7+
settings:
8+
color: false
9+
lockfile: false
10+
11+
sort:
12+
enabled: true
13+
by: name
14+
15+
# recursive can't be enabled until this bug is fixed:
16+
# https://github.com/terraform-docs/terraform-docs/issues/654
17+
recursive:
18+
enabled: false

.tflint.hcl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugin "terraform" {
2+
enabled = true
3+
preset = "recommended"
4+
}
5+
6+
rule "terraform_required_providers" {
7+
enabled = false
8+
}
9+
10+
rule "terraform_required_version" {
11+
enabled = false
12+
}

.tfsec.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
min_required_version: 1.28.1
3+
minimum_severity: LOW
4+
severity_overrides: {}
5+
exclude: []

Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
TERRAFORM := $(shell which terraform)
2+
S3_REGION := $(shell sops decrypt secrets/secrets.yaml | grep ^s3_region | cut -d ' ' -f 2)
3+
S3_BUCKET := $(shell sops decrypt secrets/secrets.yaml | grep ^s3_bucket | cut -d ' ' -f 2)
4+
S3_KEY := $(shell sops decrypt secrets/secrets.yaml | grep ^s3_key | cut -d ' ' -f 2)
5+
S3_ACCESS_KEY := $(shell sops decrypt secrets/secrets.yaml | grep ^s3_access_key | cut -d ' ' -f 2)
6+
S3_SECRET_KEY := $(shell sops decrypt secrets/secrets.yaml | grep ^s3_secret_key | cut -d ' ' -f 2)
7+
8+
.PHONY: help init plan apply test pre-commit-check-deps pre-commit-install-hooks argocd-login argocd-sync sync clean
9+
10+
help:
11+
@echo "General targets"
12+
@echo "----------------"
13+
@echo
14+
@echo "\thelp: show this help text"
15+
@echo "\tclean: removes all .terraform directories"
16+
@echo
17+
@echo "Terraform targets"
18+
@echo "-----------------"
19+
@echo
20+
@echo "\tinit: run 'terraform init'"
21+
@echo "\ttest: run pre-commmit checks"
22+
@echo "\tplan: run 'terraform plan'"
23+
@echo "\tapply: run 'terraform apply'"
24+
@echo
25+
@echo "One-time repo init targets"
26+
@echo "--------------------------"
27+
@echo
28+
@echo "\tpre-commit-install-hooks: install pre-commit hooks"
29+
@echo "\tpre-commit-check-deps: check pre-commit dependencies"
30+
@echo
31+
32+
clean:
33+
@find . -name .terraform -type d | xargs -I {} rm -rf {}
34+
35+
init: clean .terraform/terraform.tfstate
36+
37+
.terraform/terraform.tfstate:
38+
@${TERRAFORM} init -reconfigure -upgrade -input=false -backend-config="key=${S3_KEY}" -backend-config="bucket=${S3_BUCKET}" -backend-config="region=${S3_REGION}" -backend-config="access_key=${S3_ACCESS_KEY}" -backend-config="secret_key=${S3_SECRET_KEY}"
39+
40+
plan: init .terraform/plan
41+
42+
.terraform/plan:
43+
@${TERRAFORM} plan -compact-warnings -out .terraform/plan
44+
45+
apply: test plan
46+
@${TERRAFORM} apply -auto-approve -compact-warnings .terraform/plan
47+
@rm -f .terraform/plan
48+
49+
test: .git/hooks/pre-commit
50+
@pre-commit run -a
51+
52+
DEPS_PRE_COMMIT=$(shell which pre-commit || echo "pre-commit not found")
53+
DEPS_TERRAFORM_DOCS=$(shell which terraform-docs || echo "terraform-docs not found")
54+
DEPS_TFLINT=$(shell which tflint || echo "tflint not found,")
55+
DEPS_CHECKOV=$(shell which checkov || echo "checkov not found,")
56+
DEPS_JQ=$(shell which jq || echo "jq not found,")
57+
pre-commit-check-deps:
58+
@echo "Checking for pre-commit and its dependencies:"
59+
@echo " pre-commit: ${DEPS_PRE_COMMIT}"
60+
@echo " terraform-docs: ${DEPS_TERRAFORM_DOCS}"
61+
@echo " tflint: ${DEPS_TFLINT}"
62+
@echo " checkov: ${DEPS_CHECKOV}"
63+
@echo " jq: ${DEPS_JQ}"
64+
@echo ""
65+
66+
pre-commit-install-hooks: .git/hooks/pre-commit
67+
68+
.git/hooks/pre-commit: pre-commit-check-deps
69+
@pre-commit install --install-hooks
70+

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
# libvirt
2-
Terraform management of libvirt hypervisor
1+
<!-- BEGIN_TF_DOCS -->
2+
## Requirements
3+
4+
| Name | Version |
5+
|------|---------|
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | > 1.3 |
7+
| <a name="requirement_libvirt"></a> [libvirt](#requirement\_libvirt) | 0.7.1 |
8+
9+
## Providers
10+
11+
| Name | Version |
12+
|------|---------|
13+
| <a name="provider_libvirt"></a> [libvirt](#provider\_libvirt) | 0.7.1 |
14+
| <a name="provider_sops"></a> [sops](#provider\_sops) | n/a |
15+
16+
## Modules
17+
18+
No modules.
19+
20+
## Resources
21+
22+
| Name | Type |
23+
|------|------|
24+
| [libvirt_domain.runner](https://registry.terraform.io/providers/dmacvicar/libvirt/0.7.1/docs/resources/domain) | resource |
25+
| [libvirt_volume.runner](https://registry.terraform.io/providers/dmacvicar/libvirt/0.7.1/docs/resources/volume) | resource |
26+
| [sops_file.secret_vars](https://registry.terraform.io/providers/carlpett/sops/latest/docs/data-sources/file) | data source |
27+
28+
## Inputs
29+
30+
No inputs.
31+
32+
## Outputs
33+
34+
No outputs.
35+
<!-- END_TF_DOCS -->

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "sops_file" "secret_vars" {
2+
source_file = "${path.module}/secrets/secrets.yaml"
3+
}

0 commit comments

Comments
 (0)