Skip to content

Commit 8835139

Browse files
committed
Fixing workflows
1 parent 9b61aa4 commit 8835139

30 files changed

+62
-194
lines changed

.github/workflows/apply.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ jobs:
2020
- name: Run Git as root
2121
run: git config --global --add safe.directory '*'
2222

23+
- name: Install SSH key
24+
uses: shimataro/ssh-key-action@v2
25+
with:
26+
key: ${{ secrets.SSH_PRIVATE_KEY }}
27+
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
28+
29+
- name: Copy SSH area
30+
run: cp -r /root/.ssh /github/home/
31+
2332
- name: Login to OpenShift
2433
uses: redhat-actions/oc-login@v1
2534
with:

.github/workflows/plan.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ jobs:
2020
- name: Run Git as root
2121
run: git config --global --add safe.directory '*'
2222

23+
- name: Install SSH key
24+
uses: shimataro/ssh-key-action@v2
25+
with:
26+
key: ${{ secrets.SSH_PRIVATE_KEY }}
27+
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
28+
29+
- name: Copy SSH area
30+
2331
- name: Login to OpenShift
2432
uses: redhat-actions/oc-login@v1
2533
with:

Makefile

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
SHELL := /bin/bash
2+
CLUSTER_HOST := ltc.makeitwork.cloud
23
OPENSHIFT := $(shell which oc)
34
TERRAFORM := $(shell which terraform)
45
ARGOCD_URL := $(shell sops decrypt secrets/secrets.yaml | grep argocd_url | cut -d ' ' -f 2)
@@ -31,6 +32,9 @@ help:
3132
@echo "\tpre-commit-check-deps: check pre-commit dependencies"
3233
@echo
3334

35+
check-context:
36+
@if [[ "${CONTEXT}" == *"${DESIRED_CONTEXT}"* ]]; then echo "Context check passed"; else echo "Context check failed" && exit 1; fi
37+
3438
clean:
3539
@find . -name .terraform -type d | xargs -I {} rm -rf {}
3640

@@ -40,18 +44,25 @@ init: check-context clean .terraform/terraform.tfstate
4044
@${OPENSHIFT} get project ${OPENSHIFT_TF_NAMESPACE} > /dev/null 2>&1 || ${OPENSHIFT} new-project ${OPENSHIFT_TF_NAMESPACE}
4145
@${TERRAFORM} init -reconfigure -upgrade -input=false -backend-config="host=https://${OPENSHIFT_API_URL}" -backend-config="namespace=${OPENSHIFT_TF_NAMESPACE}"
4246

43-
plan: init .terraform/plan
47+
plan: ansible-check init .terraform/plan
4448

4549
.terraform/plan:
46-
@${TERRAFORM} state show kubernetes_manifest.openshift_gitops_subscription >/dev/null 2>&1 && ${TERRAFORM} plan -compact-warnings -out .terraform/plan || ${TERRAFORM} plan -compact-warnings -out .terraform/plan -target kubernetes_manifest.openshift_gitops_subscription
50+
@${TERRAFORM} plan -compact-warnings -out .terraform/plan
4751

48-
initial-deployment-apply:
49-
@${TERRAFORM} state show kubernetes_manifest.openshift_gitops_subscription >/dev/null 2>&1 || ( echo "INITIAL DEPLOYMENT" && ${TERRAFORM} apply -auto-approve -compact-warnings -target kubernetes_manifest.openshift_gitops_subscription .terraform/plan && rm -f .terraform/plan && echo "WAITING FOR GITOPS DEPLOYMENT" && while true; do oc get argocd -n openshift-gitops openshift-gitops >/dev/null 2>&1 && sleep 10 && break; sleep 2; done && oc apply -k kustomize && echo "WAITING FOR CHANGES TO BE DEPLOYED" && while true; do oc get argocd openshift-gitops -n openshift-gitops -o yaml | grep KSOPS >/dev/null 2>&1 && sleep 10 && break; sleep 2; done && ${TERRAFORM} plan -compact-warnings -out .terraform/plan )
52+
ansible-check:
53+
@rm -rf ~/.ansible >/dev/null 2>&1
54+
@ansible-galaxy install -r ansible/requirements.yml
55+
@ansible/site.yml -i "${CLUSTER_HOST}," -C --diff
5056

51-
apply: test plan initial-deployment-apply
57+
apply: ansible-init test plan
5258
@${TERRAFORM} apply -auto-approve -compact-warnings .terraform/plan
5359
@rm -f .terraform/plan
5460

61+
ansible-init:
62+
@rm -rf ~/.ansible >/dev/null 2>&1
63+
@ansible-galaxy install -r ansible/requirements.yml
64+
@ansible/site.yml -i "${CLUSTER_HOST},"
65+
5566
test: check-context .git/hooks/pre-commit
5667
@pre-commit run -a
5768

@@ -74,19 +85,18 @@ pre-commit-install-hooks: .git/hooks/pre-commit
7485
.git/hooks/pre-commit: pre-commit-check-deps
7586
@pre-commit install --install-hooks
7687

77-
check-context:
78-
@ if [[ "${CONTEXT}" == *"${DESIRED_CONTEXT}"* ]]; then echo "Context check passed"; else echo "Context check failed" && exit 1; fi
7988

8089
argocd-password:
81-
@ ${OPENSHIFT} get secret openshift-gitops-cluster -n openshift-gitops -o jsonpath='{.data.admin\.password}' | base64 -d
82-
@ echo
90+
@${OPENSHIFT} get secret openshift-gitops-cluster -n openshift-gitops -o jsonpath='{.data.admin\.password}' | base64 -d
91+
@echo
8392

8493
password: argocd-password
8594

8695
argocd-login:
87-
@ argocd login --skip-test-tls --insecure --username admin --password "$(shell ${OPENSHIFT} get secret openshift-gitops-cluster -n openshift-gitops -o jsonpath='{.data.admin\.password}' | base64 -d)" ${ARGOCD_URL}
96+
@argocd login --skip-test-tls --insecure --username admin --password "$(shell ${OPENSHIFT} get secret openshift-gitops-cluster -n openshift-gitops -o jsonpath='{.data.admin\.password}' | base64 -d)" ${ARGOCD_URL}
8897

8998
argocd-sync: argocd-login
90-
@ argocd app sync gitops-configs
99+
@argocd app sync gitops-configs
91100

92101
sync: argocd-sync
102+

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ No modules.
2222
|------|------|
2323
| [kubernetes_cluster_role_binding.openshift_gitops_cluster_admin](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/cluster_role_binding) | resource |
2424
| [kubernetes_manifest.argocd_kustomize_app](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource |
25-
| [kubernetes_manifest.openshift_gitops_operator_group](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource |
26-
| [kubernetes_manifest.openshift_gitops_subscription](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource |
27-
| [kubernetes_namespace.openshift_gitops](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
2825
| [kubernetes_secret.argocd_github_repo_secret](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret) | resource |
29-
| [kubernetes_secret.sops_age_key](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret) | resource |
3026
| [sops_file.secret_vars](https://registry.terraform.io/providers/carlpett/sops/latest/docs/data-sources/file) | data source |
3127

3228
## Inputs

ansible/gitops.yml

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

ansible/requirements.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
- src: https://github.com/makeitworkcloud/ansible-crc
1+
---
2+
- name: crc
3+
src: https://github.com/makeitworkcloud/ansible-crc
4+
- name: ksopsgitops
5+
src: https://github.com/makeitworkcloud/ansible-ksops

ansible/site.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ansible-playbook
2+
---
3+
- name: Deploy OpenShift Local + GitOps
4+
gather_facts: true
5+
hosts: all
6+
roles:
7+
- crc
8+
- ksopsgitops

argocd.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ resource "kubernetes_secret" "argocd_github_repo_secret" {
1212
project = "default"
1313
type = "git"
1414
}
15-
depends_on = [kubernetes_manifest.openshift_gitops_subscription]
15+
depends_on = [kubernetes_cluster_role_binding.openshift_gitops_cluster_admin]
1616
}
1717

1818
resource "kubernetes_manifest" "argocd_kustomize_app" {
@@ -27,7 +27,7 @@ resource "kubernetes_manifest" "argocd_kustomize_app" {
2727
project = "default"
2828
source = {
2929
repoURL = "https://github.com/makeitworkcloud/cluster.git"
30-
path = "gitops-configs"
30+
path = "kustomize"
3131
targetRevision = "main"
3232
}
3333
destination = {
@@ -43,3 +43,4 @@ resource "kubernetes_manifest" "argocd_kustomize_app" {
4343
}
4444
depends_on = [kubernetes_secret.argocd_github_repo_secret]
4545
}
46+

gitops-configs/external-dns/kustomization.yaml

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

gitops-configs/external-dns/operator.yaml

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

0 commit comments

Comments
 (0)