Skip to content

Commit 5f9cd2c

Browse files
committed
yamllint
1 parent 5a8bdd8 commit 5f9cd2c

File tree

24 files changed

+305
-251
lines changed

24 files changed

+305
-251
lines changed

.gitlab-ci.yml

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
include:
2-
- project: 'devops/cicd'
3-
ref: main
4-
file: '/scripts/set_ssh_key.yml'
5-
1+
---
2+
include:
63
- local: '.gitlab/ci/invidious.yml'
74

85
stages:
9-
- sync
6+
- lint
107
- update_services
8+
- sync
9+
10+
yaml_lint:
11+
stage: lint
12+
image: python:3.10
13+
script:
14+
- pip install yamllint
15+
- yamllint . -c .yamllint
16+
only:
17+
changes:
18+
- "**/*.yml"
19+
- "**/*.yml.j2"
20+
- "**/*.yaml"
21+
- "**/*.yaml.j2"
22+
allow_failure: true
1123

1224
sync-to-clean:
1325
stage: sync
@@ -20,44 +32,45 @@ sync-to-clean:
2032
# Installazione delle dipendenze necessarie
2133
- apk add --no-cache git rsync
2234
script:
23-
# Step 1: Estrazione delle informazioni della commit corrente
24-
- COMMIT_AUTHOR_NAME=$(git log -1 --pretty=format:"%an")
25-
- COMMIT_AUTHOR_EMAIL=$(git log -1 --pretty=format:"%ae")
26-
- COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
27-
28-
# Step 2: Clonare il repository homelab-clean utilizzando il token CI già disponibile
29-
- git clone https://${GIT_USERNAME}:${SYNC_PAT_TOKEN}@${CI_SERVER_HOST}/${GIT_USERNAME}/homelab-clean.git /tmp/homelab-clean
30-
31-
# Step 3: Eliminare tutto tranne la cartella .git dal repository clonato
32-
- find /tmp/homelab-clean -mindepth 1 -path "/tmp/homelab-clean/.git" -prune -o -exec rm -rf {} \; 2>/dev/null || true
33-
34-
# Step 4: Copiare il contenuto del repository attuale (tranne .git) nel repository clonato
35-
- rsync -av --exclude='.git' $CI_PROJECT_DIR/ /tmp/homelab-clean/
36-
37-
# Step 5: Eliminare le cartelle e i file specificati nel file .exclude_from_github
38-
- cd /tmp/homelab-clean
39-
40-
# Verificare se il file .exclude_from_github esiste
41-
- if [ -f ".exclude_from_github" ]; then
42-
- echo "File .exclude_from_github trovato, elaborazione delle esclusioni..."
43-
- while IFS= read -r item || [ -n "$item" ]; do
44-
- if [ -n "$item" ] && [[ ! "$item" =~ ^\s*# ]]; then
45-
- item=$(echo $item | xargs) # Rimuove eventuali spazi bianchi
46-
- echo "Rimozione di $item"
47-
- rm -rf "$item"
48-
- fi
49-
- done < .exclude_from_github
50-
- rm -f .exclude_from_github
51-
- else
52-
- echo "File .exclude_from_github non trovato, nessuna esclusione da applicare"
53-
- fi
54-
55-
# Maschera la mail
56-
- find . -type f \( -name "*.yml" -o -name "*.yaml" -o -name "*.md" -o -name "*.j2" -o -name "*.json" \) -exec sed -i "s/$(echo ${EMAIL_TO_MASK} | sed 's/[\/&]/\\&/g')/[email protected]/g" {} \;
57-
58-
# Step 6: Commit e push delle modifiche con lo stesso autore e messaggio originale
59-
- git add .
60-
- git config user.name "$COMMIT_AUTHOR_NAME"
61-
- git config user.email "$COMMIT_AUTHOR_EMAIL"
62-
- git commit -m "$COMMIT_MESSAGE" || echo "No changes to commit"
63-
- git push https://${GIT_USERNAME}:${SYNC_PAT_TOKEN}@${CI_SERVER_HOST}/${GIT_USERNAME}/homelab-clean.git main
35+
- |
36+
# Step 1: Estrazione delle informazioni della commit corrente
37+
COMMIT_AUTHOR_NAME=$(git log -1 --pretty=format:"%an")
38+
COMMIT_AUTHOR_EMAIL=$(git log -1 --pretty=format:"%ae")
39+
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
40+
41+
# Step 2: Clonare il repository homelab-clean utilizzando il token CI già disponibile
42+
git clone https://${GIT_USERNAME}:${SYNC_PAT_TOKEN}@${CI_SERVER_HOST}/${GIT_USERNAME}/homelab-clean.git /tmp/homelab-clean
43+
44+
# Step 3: Eliminare tutto tranne la cartella .git dal repository clonato
45+
find /tmp/homelab-clean -mindepth 1 -path "/tmp/homelab-clean/.git" -prune -o -exec rm -rf {} \; 2>/dev/null || true
46+
47+
# Step 4: Copiare il contenuto del repository attuale (tranne .git) nel repository clonato
48+
rsync -av --exclude='.git' $CI_PROJECT_DIR/ /tmp/homelab-clean/
49+
50+
# Step 5: Eliminare le cartelle e i file specificati nel file .exclude_from_github
51+
cd /tmp/homelab-clean
52+
53+
# Verificare se il file .exclude_from_github esiste
54+
if [ -f ".exclude_from_github" ]; then
55+
echo "File .exclude_from_github trovato, elaborazione delle esclusioni..."
56+
while IFS= read -r item || [ -n "$item" ]; do
57+
if [ -n "$item" ] && [[ ! "$item" =~ ^\s*# ]]; then
58+
item=$(echo $item | xargs) # Rimuove eventuali spazi bianchi
59+
echo "Rimozione di $item"
60+
rm -rf "$item"
61+
fi
62+
done < .exclude_from_github
63+
rm -f .exclude_from_github
64+
else
65+
echo "File .exclude_from_github non trovato, nessuna esclusione da applicare"
66+
fi
67+
68+
# Maschera la mail
69+
find . -type f \( -name "*.yml" -o -name "*.yaml" -o -name "*.md" -o -name "*.j2" -o -name "*.json" \) -exec sed -i "s/$(echo ${EMAIL_TO_MASK} | sed 's/[\/&]/\\&/g')/[email protected]/g" {} \;
70+
71+
# Step 6: Commit e push delle modifiche con lo stesso autore e messaggio originale
72+
git add .
73+
git config user.name "$COMMIT_AUTHOR_NAME"
74+
git config user.email "$COMMIT_AUTHOR_EMAIL"
75+
git commit -m "$COMMIT_MESSAGE" || echo "No changes to commit"
76+
git push https://${GIT_USERNAME}:${SYNC_PAT_TOKEN}@${CI_SERVER_HOST}/${GIT_USERNAME}/homelab-clean.git main

.gitlab/ci/invidious.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
include:
2+
- project: 'devops/cicd'
3+
ref: main
4+
file: '/jobs/set_ssh_key.yml'
5+
16
.rules_update_invidious:
27
rules:
38
- if: '$CI_COMMIT_BRANCH == "master"'
@@ -9,7 +14,9 @@ update_invidious:
914
image: docker:latest
1015
services:
1116
- docker:dind
12-
extends: .rules_update_invidious
17+
extends:
18+
- .rules_update_invidious
19+
- .ssh_setup
1320
variables:
1421
DOCKER_DRIVER: overlay2
1522
SERVER_IP: $INVIDIOUS_SSH_SERVER_IP

.yamllint

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length:
6+
max: 120
7+
level: warning
8+
9+
indentation:
10+
spaces: 2
11+
indent-sequences: consistent
12+
13+
trailing-spaces: enable
14+
15+
comments:
16+
level: warning
17+
min-spaces-from-content: 1
18+
19+
braces:
20+
min-spaces-inside: 0
21+
max-spaces-inside: 1
22+
23+
brackets:
24+
min-spaces-inside: 0
25+
max-spaces-inside: 0
26+
27+
document-start: enable

ansible/argocd-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- name: Imposta variabili globali
23
hosts: localhost
34
gather_facts: false

ansible/argocd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- name: Install ArgoCD
23
hosts: localhost
34
become: true

ansible/cka.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

ansible/gitea.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- name: Configure gitea
23
hosts: gitea
34
become: true

ansible/inventory/group_vars/all.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
current_username: filippo
23
# ansible_python_interpreter: /usr/bin/python3
34

@@ -14,9 +15,9 @@ pihole:
1415
- { ip: 192.168.0.145, domain: "pihole" }
1516
- { ip: 192.168.0.167, domain: "pihole2" }
1617
- { ip: 192.168.0.183, domain: "ubuntu" }
17-
18+
1819
- { ip: 192.168.0.50, domain: "vault" }
19-
20+
2021
- { ip: 192.168.0.80, domain: "argocd.local.ildoc.it" }
2122
- { ip: 192.168.0.80, domain: "longhorn.local.ildoc.it" }
2223
- { ip: 192.168.0.80, domain: "rancher.local.ildoc.it" }
@@ -49,11 +50,11 @@ pihole:
4950
- { ip: 192.168.0.80, domain: "audiobookshelf.local.ildoc.it" }
5051
- { ip: 192.168.0.25, domain: "gitlab.local.ildoc.it" }
5152
- { ip: 192.168.0.25, domain: "registry.gitlab.local.ildoc.it" }
52-
53+
5354
- { ip: 192.168.0.100, domain: "argocd2.local.ildoc.it" }
5455
- { ip: 192.168.0.100, domain: "traefik2.local.ildoc.it" }
5556
- { ip: 192.168.0.100, domain: "rancher2.local.ildoc.it" }
56-
57+
5758
dhcp_reservations:
5859
- { mac: 60:83:E7:AC:6C:68, ip: 192.168.0.175, hostname: archlinux }
5960
- { mac: 02:F1:76:00:ED:DD, ip: 192.168.0.133, hostname: homeassistant }

ansible/invidious.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- name: Configure invidious
23
hosts: invidious
34
gather_facts: true

ansible/kubernetes-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- name: Imposta variabili globali
23
hosts: k8s_test
34
gather_facts: false

0 commit comments

Comments
 (0)