opentofu
2 minute read
Ten pipeline GitLab CI/CD został zaprojektowany do kompleksowej obsługi projektów OpenTofu - Infrastructure as a Code.
Celem jest zapewnienie wysokiej jakości kodu, spójności dokumentacji oraz bezpiecznego wdrażania infrastruktury.
Gitlab-ci pipeline
---
config:
theme: redux
---
flowchart LR
subgraph s1["validate"]
n1["🧑💻 YAML lint"]
n8@{ label: "<code><span class=\"hljs-string\">🕵</span><span class=\"\"> </span><span class=\"hljs-attr\">opentofu fmt</span></code>" }
n9@{ label: "<code><span class=\"hljs-string\">✅</span><span class=\"\"> </span><span class=\"hljs-attr\">opentofu validate</span></code>" }
n10@{ label: "<code><span class=\"hljs-string\">✅</span><span class=\"\"> </span><span class=\"hljs-attr\">tflint</span></code>" }
n11@{ label: "<code><span class=\"hljs-string\">✅</span><span class=\"\"> </span><span class=\"hljs-attr\">opentofu-docs</span></code>" }
end
subgraph s2["prepare"]
n2["🔍 Analyze Conventional Commits"]
n3["🔍 input parameters"]
n4["🕵 Set Version"]
end
subgraph s3["sast"]
n5["💪 sonarqube scan"]
end
subgraph s4["release"]
n6["📍 Publish Version"]
end
subgraph s5["unit-test"]
n12@{ label: "<span style=\"color:\" color=\"\">🧪 opentofu plan</span>" }
end
subgraph s6["deploy"]
n13@{ label: "<span style=\"color:\" color=\"\">💥 opentofu apply</span>" }
end
s2 --> s1
n2 --- n3
n3 --- n4
s3 --> s4
s1 --> s5
n1 --- n8
n8 --> n9
n9 --> n10
n10 --> n11
s5 --> s3
s4 --> s6
n8@{ shape: rect}
n9@{ shape: rect}
n10@{ shape: rect}
n11@{ shape: rect}
n12@{ shape: rect}
n13@{ shape: rect}
click n1 "https://gitlab.com/pl.rachuna-net/cicd/components/validate/-/blob/main/templates/yamllint.yml?ref_type=heads"
click n8 "https://gitlab.com/pl.rachuna-net/cicd/components/infrastructure/-/blob/main/templates/opentofu.yml?ref_type=heads"
click n9 "https://gitlab.com/pl.rachuna-net/cicd/components/infrastructure/-/blob/main/templates/opentofu.yml?ref_type=heads"
click n10 "https://gitlab.com/pl.rachuna-net/cicd/components/infrastructure/-/blob/main/templates/opentofu.yml?ref_type=heads"
click n11 "https://gitlab.com/pl.rachuna-net/cicd/components/infrastructure/-/blob/main/templates/opentofu.yml?ref_type=heads"
click n2 "https://gitlab.com/pl.rachuna-net/cicd/components/prepare/-/blob/main/templates/conventional_commits.yml?ref_type=heads"
click n3 "https://gitlab.com/pl.rachuna-net/cicd/components/prepare/-/blob/main/templates/input_parameters.yml?ref_type=heads"
click n4 "https://gitlab.com/pl.rachuna-net/cicd/components/release/-/blob/main/templates/versioning.yml"
click n5 "https://gitlab.com/pl.rachuna-net/cicd/components/ast/-/blob/main/templates/sonarqube.yml?ref_type=heads"
click n6 "https://gitlab.com/pl.rachuna-net/cicd/components/release/-/blob/main/templates/versioning.yml"
click n12 "https://gitlab.com/pl.rachuna-net/cicd/components/infrastructure/-/blob/main/templates/opentofu.yml?ref_type=heads"
click n13 "https://gitlab.com/pl.rachuna-net/cicd/components/infrastructure/-/blob/main/templates/opentofu.yml?ref_type=heads"
| Stage | Job | Opis |
|---|---|---|
| prepare | 🔍 input parameters | Wyświetlenie i weryfikacja parametrów wejściowych procesu CI. |
| prepare | 🔍 Analyze Conventional Commits | Analiza konwencji commitów (Conventional Commits) w celu oceny poprawności i wyznaczenia zmian (feat/fix/chore). |
| prepare | 🕵 Set Version | Ustalanie wersji aplikacji na podstawie commitów i reguł wersjonowania semantycznego. |
| validate | 🧑💻 YAML lint | Lintowanie i walidacja składni plików YAML. |
| validate | 🕵 opentofu fmt | Formatowanie plików OpenTofu/Terraform zgodnie ze standardem. |
| validate | ✅ opentofu validate | Walidacja konfiguracji OpenTofu (składnia, zależności, providerzy). |
| validate | ✅ tflint | Lint reguł dla Terraform/OpenTofu (best practices, błędy konfiguracyjne). |
| validate | ✅ opentofu-docs | Generowanie/aktualizacja dokumentacji modułów OpenTofu (np. README, zmienne, wyjścia). |
| unit-test | 🧪 opentofu plan | „Suchy bieg” – plan zmian infrastruktury jako test poprawności i wpływu zmian. |
| sast | 💪 sonarqube scan | Analiza statyczna kodu (SAST) z wykorzystaniem SonarQube. |
| release | 📍 Publish Version | Publikacja wersji (tagowanie, release, ewentualny upload artefaktów). |
| deploy | 💥 opentofu apply | Zastosowanie planu zmian infrastruktury (wdrożenie) w środowisku. |