Refactor gitops repositories;Move capi manifests to subfolder;Sort components in tty console message;Generalize templates
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1c60214f5a
commit
933615adeb
@ -41,7 +41,7 @@
|
|||||||
_template:
|
_template:
|
||||||
name: argocd-gitrepo-metacluster
|
name: argocd-gitrepo-metacluster
|
||||||
namespace: argo-cd
|
namespace: argo-cd
|
||||||
uid: "{{ lookup('ansible.builtin.password', '/dev/null length=5 chars=ascii_lowercase,digits seed=inventory_hostname') }}"
|
url: https://git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.Config.git
|
||||||
privatekey: "{{ lookup('ansible.builtin.file', '~/.ssh/git_rsa_id') | indent(4, true) }}"
|
privatekey: "{{ lookup('ansible.builtin.file', '~/.ssh/git_rsa_id') | indent(4, true) }}"
|
||||||
notify:
|
notify:
|
||||||
- Apply manifests
|
- Apply manifests
|
||||||
@ -49,14 +49,19 @@
|
|||||||
- name: Create applicationset
|
- name: Create applicationset
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: applicationset.j2
|
src: applicationset.j2
|
||||||
dest: /var/lib/rancher/k3s/server/manifests/{{ _template.name }}-manifest.yaml
|
dest: /var/lib/rancher/k3s/server/manifests/{{ _template.application.name }}-manifest.yaml
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0600
|
mode: 0600
|
||||||
vars:
|
vars:
|
||||||
_template:
|
_template:
|
||||||
name: argocd-applicationset-metacluster
|
application:
|
||||||
namespace: argo-cd
|
name: argocd-applicationset-metacluster
|
||||||
|
namespace: argo-cd
|
||||||
|
cluster:
|
||||||
|
name: https://kubernetes.default.svc
|
||||||
|
repository:
|
||||||
|
url: https://git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.Config.git
|
||||||
notify:
|
notify:
|
||||||
- Apply manifests
|
- Apply manifests
|
||||||
|
|
||||||
|
@ -137,9 +137,9 @@
|
|||||||
chdir: /opt/metacluster/cluster-api
|
chdir: /opt/metacluster/cluster-api
|
||||||
register: clusterctl_newcluster
|
register: clusterctl_newcluster
|
||||||
|
|
||||||
- name: Initialize tempfile
|
- name: Initialize tempfolder
|
||||||
ansible.builtin.tempfile:
|
ansible.builtin.tempfile:
|
||||||
state: file
|
state: directory
|
||||||
register: capi_clustermanifest
|
register: capi_clustermanifest
|
||||||
|
|
||||||
- name: Save workload cluster manifest
|
- name: Save workload cluster manifest
|
||||||
@ -152,7 +152,7 @@
|
|||||||
cmd: >-
|
cmd: >-
|
||||||
kubectl slice \
|
kubectl slice \
|
||||||
-f {{ capi_clustermanifest.path }} \
|
-f {{ capi_clustermanifest.path }} \
|
||||||
-o /opt/metacluster/cluster-api/new-cluster
|
-o {{ capi_clustermanifest.path }}/manifests
|
||||||
|
|
||||||
- name: Initialize/Push git repository
|
- name: Initialize/Push git repository
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
@ -161,17 +161,18 @@
|
|||||||
git config --global user.email "administrator@{{ vapp['metacluster.fqdn'] }}"
|
git config --global user.email "administrator@{{ vapp['metacluster.fqdn'] }}"
|
||||||
git config --global user.name "administrator"
|
git config --global user.name "administrator"
|
||||||
git checkout -b main
|
git checkout -b main
|
||||||
git add .
|
git add ./manifests
|
||||||
git commit -m "Upload manifests"
|
git commit -m "Upload manifests"
|
||||||
git remote add origin https://git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.ClusterAPI.git
|
git remote add origin https://git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.ClusterAPI.git
|
||||||
git push https://administrator:{{ vapp['metacluster.password'] | urlencode }}@git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.ClusterAPI.git --all
|
git push https://administrator:{{ vapp['metacluster.password'] | urlencode }}@git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.ClusterAPI.git --all
|
||||||
chdir: /opt/metacluster/cluster-api/new-cluster
|
chdir: "{{ capi_clustermanifest.path }}"
|
||||||
|
|
||||||
- name: Cleanup tempfile
|
# Temporarily disabled until manifests are properly managed by gitops
|
||||||
ansible.builtin.file:
|
# - name: Cleanup tempfolder
|
||||||
path: "{{ capi_clustermanifest.path }}"
|
# ansible.builtin.file:
|
||||||
state: absent
|
# path: "{{ capi_clustermanifest.path }}"
|
||||||
when: capi_clustermanifest.path is defined
|
# state: absent
|
||||||
|
# when: capi_clustermanifest.path is defined
|
||||||
|
|
||||||
- name: Create in-cluster IpPool
|
- name: Create in-cluster IpPool
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
|
@ -53,6 +53,45 @@
|
|||||||
url: https://{{ vapp['workloadcluster.vip'] }}:6443
|
url: https://{{ vapp['workloadcluster.vip'] }}:6443
|
||||||
token: "{{ workloadcluster_bearertoken.resources | json_query('[].data.token') }}"
|
token: "{{ workloadcluster_bearertoken.resources | json_query('[].data.token') }}"
|
||||||
|
|
||||||
|
- name: Configure workload-cluster GitOps repository
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: gitrepo.j2
|
||||||
|
dest: /var/lib/rancher/k3s/server/manifests/{{ _template.name }}-manifest.yaml
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0600
|
||||||
|
vars:
|
||||||
|
_template:
|
||||||
|
name: argocd-gitrepo-workloadcluster
|
||||||
|
namespace: argo-cd
|
||||||
|
url: https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
|
||||||
|
privatekey: "{{ lookup('ansible.builtin.file', '~/.ssh/git_rsa_id') | indent(4, true) }}"
|
||||||
|
notify:
|
||||||
|
- Apply manifests
|
||||||
|
|
||||||
|
- name: Create applicationset
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: applicationset.j2
|
||||||
|
dest: /var/lib/rancher/k3s/server/manifests/{{ _template.application.name }}-manifest.yaml
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0600
|
||||||
|
vars:
|
||||||
|
_template:
|
||||||
|
application:
|
||||||
|
name: argocd-applicationset-workloadcluster
|
||||||
|
namespace: argo-cd
|
||||||
|
cluster:
|
||||||
|
name: "{{ vapp['workloadcluster.name'] | lower }}"
|
||||||
|
repository:
|
||||||
|
url: https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
|
||||||
|
|
||||||
|
notify:
|
||||||
|
- Apply manifests
|
||||||
|
|
||||||
|
- name: Trigger handlers
|
||||||
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
_template:
|
_template:
|
||||||
account:
|
account:
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
apiVersion: argoproj.io/v1alpha1
|
apiVersion: argoproj.io/v1alpha1
|
||||||
kind: ApplicationSet
|
kind: ApplicationSet
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ _template.name }}
|
name: {{ _template.application.name }}
|
||||||
namespace: {{ _template.namespace }}
|
namespace: {{ _template.application.namespace }}
|
||||||
spec:
|
spec:
|
||||||
generators:
|
generators:
|
||||||
- git:
|
- git:
|
||||||
repoURL: https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
|
repoURL: {{ _template.repository.url }}
|
||||||
revision: HEAD
|
revision: HEAD
|
||||||
directories:
|
directories:
|
||||||
- path: metacluster-applicationset/*
|
- path: applicationset/*
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
name: {% raw %}'{{ path.basename }}'{% endraw +%}
|
name: {% raw %}'{{ path.basename }}'{% endraw +%}
|
||||||
@ -20,9 +20,9 @@ spec:
|
|||||||
prune: true
|
prune: true
|
||||||
selfHeal: true
|
selfHeal: true
|
||||||
source:
|
source:
|
||||||
repoURL: https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
|
repoURL: {{ _template.repository.url }}
|
||||||
targetRevision: HEAD
|
targetRevision: HEAD
|
||||||
path: {% raw %}'{{ path }}'{% endraw +%}
|
path: {% raw %}'{{ path }}'{% endraw +%}
|
||||||
destination:
|
destination:
|
||||||
server: https://kubernetes.default.svc
|
server: {{ _template.cluster.name }}
|
||||||
namespace: default
|
namespace: default
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ _template.name }}-{{ _template.uid }}
|
name: {{ _template.name }}
|
||||||
namespace: {{ _template.namespace }}
|
namespace: {{ _template.namespace }}
|
||||||
labels:
|
labels:
|
||||||
argocd.argoproj.io/secret-type: repository
|
argocd.argoproj.io/secret-type: repository
|
||||||
stringData:
|
stringData:
|
||||||
url: ssh://git@gitea-ssh.gitea.svc.cluster.local/mc/GitOps.Config.git
|
url: {{ _template.url }}
|
||||||
name: {{ _template.name }}
|
name: {{ _template.name }}
|
||||||
insecure: 'true'
|
insecure: 'true'
|
||||||
sshPrivateKey: |
|
sshPrivateKey: |
|
||||||
|
@ -33,7 +33,7 @@ while /bin/true; do
|
|||||||
echo -e "${PRST}" > /dev/tty1
|
echo -e "${PRST}" > /dev/tty1
|
||||||
echo -e "\n\n\t${DFLT}To manage this appliance, please connect to one of the following:${LCLR}\n" > /dev/tty1
|
echo -e "\n\n\t${DFLT}To manage this appliance, please connect to one of the following:${LCLR}\n" > /dev/tty1
|
||||||
|
|
||||||
for c in "${!COMPONENTS[@]}"; do
|
for c in $( echo "${!COMPONENTS[@]}" | tr ' ' $'\n' | sort); do
|
||||||
STATUS=$(curl -kLs "${COMPONENTS[${c}]}" -o /dev/null -w '%{http_code}')
|
STATUS=$(curl -kLs "${COMPONENTS[${c}]}" -o /dev/null -w '%{http_code}')
|
||||||
|
|
||||||
if [[ "${STATUS}" -eq "200" ]]; then
|
if [[ "${STATUS}" -eq "200" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user