From 61684f67494094a1c35bf0988aea473d6e1e8e62 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 02:47:08 +0000 Subject: [PATCH 1/9] Implement deploy jobs for all IaC hosts --- homelab/.gitlab-ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/homelab/.gitlab-ci.yml b/homelab/.gitlab-ci.yml index 35401ecf..e74846a8 100644 --- a/homelab/.gitlab-ci.yml +++ b/homelab/.gitlab-ci.yml @@ -1,4 +1,5 @@ stages: + - test - deploy before_script: @@ -11,6 +12,7 @@ before_script: - ssh-add <(echo "$SSH_PRIVATE_KEY") - mkdir -p ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + server-deploy: stage: deploy @@ -21,3 +23,23 @@ server-deploy: when: manual script: - ssh joey@joey-server "cd /home/joey/homelab && git pull" + +seedbox-deploy: + stage: deploy + when: always + rules: + - changes: + - seedbox/ + when: manual + script: + - ssh joey@joey-seedbox "cd /home/joey/homelab && git pull" + +jafner-tools-deploy: + stage: deploy + when: always + rules: + - changes: + - jafner-tools/ + when: manual + script: + - ssh root@jafner.tools "cd /root/homelab && git pull" \ No newline at end of file From b0e912c97d20e81424def6eee5571cb2f29c2ee0 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 02:47:23 +0000 Subject: [PATCH 2/9] Implement deploy jobs for all IaC hosts From 30eae7e444d3548cc237ca0fdf439f84d0cf5f84 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 03:09:54 +0000 Subject: [PATCH 3/9] Update .gitlab-ci.yml file --- homelab/.gitlab-ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/homelab/.gitlab-ci.yml b/homelab/.gitlab-ci.yml index e74846a8..be5d7257 100644 --- a/homelab/.gitlab-ci.yml +++ b/homelab/.gitlab-ci.yml @@ -12,6 +12,18 @@ before_script: - ssh-add <(echo "$SSH_PRIVATE_KEY") - mkdir -p ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + +docker-compose-test: + image: docker/compose + stage: test + when: always + rules: + - changes: + - docker-compose.yml + - server/config/minecraft/ + when: manual + script: + - ls server-deploy: From 4aa9ec5882e1ef4760731fa2311a28d30cc162d7 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 03:11:06 +0000 Subject: [PATCH 4/9] Update .gitlab-ci.yml file --- homelab/.gitlab-ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/homelab/.gitlab-ci.yml b/homelab/.gitlab-ci.yml index be5d7257..5b9f9daf 100644 --- a/homelab/.gitlab-ci.yml +++ b/homelab/.gitlab-ci.yml @@ -3,9 +3,6 @@ stages: - deploy before_script: - # update and install git - - apt-get update -qq - - apt-get install -qq git # configure SSH keys - 'which ssh-agent || ( apt-get install -qq openssh-client )' - eval $(ssh-agent -s) From 160660878ca50cb5a560e1ac56a0faa1f03d3e81 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 03:12:35 +0000 Subject: [PATCH 5/9] Update .gitlab-ci.yml file --- homelab/.gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/homelab/.gitlab-ci.yml b/homelab/.gitlab-ci.yml index 5b9f9daf..2d5710e7 100644 --- a/homelab/.gitlab-ci.yml +++ b/homelab/.gitlab-ci.yml @@ -1,8 +1,12 @@ +image: debian:bullseye + stages: - test - deploy before_script: + - apt-get update + - apt-get install git docker docker-compose # configure SSH keys - 'which ssh-agent || ( apt-get install -qq openssh-client )' - eval $(ssh-agent -s) From 33b709bac9afdba219260d14290197b2228f5e83 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 03:12:47 +0000 Subject: [PATCH 6/9] Update .gitlab-ci.yml file --- homelab/.gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/homelab/.gitlab-ci.yml b/homelab/.gitlab-ci.yml index 2d5710e7..6c6cb841 100644 --- a/homelab/.gitlab-ci.yml +++ b/homelab/.gitlab-ci.yml @@ -15,7 +15,6 @@ before_script: - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' docker-compose-test: - image: docker/compose stage: test when: always rules: From 272537e080708d88c368b61e82a442a65987acdb Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 03:19:44 +0000 Subject: [PATCH 7/9] Update .gitlab-ci.yml file --- homelab/.gitlab-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homelab/.gitlab-ci.yml b/homelab/.gitlab-ci.yml index 6c6cb841..0f5a52b3 100644 --- a/homelab/.gitlab-ci.yml +++ b/homelab/.gitlab-ci.yml @@ -1,5 +1,3 @@ -image: debian:bullseye - stages: - test - deploy @@ -15,6 +13,7 @@ before_script: - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' docker-compose-test: + image: debian:bullseye stage: test when: always rules: @@ -27,6 +26,7 @@ docker-compose-test: server-deploy: + image: debian:bullseye stage: deploy when: always rules: @@ -37,6 +37,7 @@ server-deploy: - ssh joey@joey-server "cd /home/joey/homelab && git pull" seedbox-deploy: + image: debian:bullseye stage: deploy when: always rules: @@ -47,6 +48,7 @@ seedbox-deploy: - ssh joey@joey-seedbox "cd /home/joey/homelab && git pull" jafner-tools-deploy: + image: debian:bullseye stage: deploy when: always rules: From 0179cb0e615644332ef46dec68765a1746e1dc9b Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 03:21:53 +0000 Subject: [PATCH 8/9] Update .gitlab-ci.yml file --- homelab/.gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homelab/.gitlab-ci.yml b/homelab/.gitlab-ci.yml index 0f5a52b3..8dbdf89c 100644 --- a/homelab/.gitlab-ci.yml +++ b/homelab/.gitlab-ci.yml @@ -3,8 +3,8 @@ stages: - deploy before_script: - - apt-get update - - apt-get install git docker docker-compose + - apt-get -y update + - apt-get -y install git docker docker-compose # configure SSH keys - 'which ssh-agent || ( apt-get install -qq openssh-client )' - eval $(ssh-agent -s) From 0befa64b35b40b7d8ada0f476b00d8bd92f43b17 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 26 Feb 2022 03:52:22 +0000 Subject: [PATCH 9/9] Implement docker-compose config linter --- homelab/.gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homelab/.gitlab-ci.yml b/homelab/.gitlab-ci.yml index 8dbdf89c..7e43ba04 100644 --- a/homelab/.gitlab-ci.yml +++ b/homelab/.gitlab-ci.yml @@ -22,7 +22,10 @@ docker-compose-test: - server/config/minecraft/ when: manual script: - - ls + - find ~+ -type f -name docker-compose.yml > composes.txt + - find ~+/server/config/minecraft/ -type f -name *.yml >> composes.txt + - for file in `cat composes.txt`; do docker-compose -f $file config; done + - rm composes.txt server-deploy: