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:
@ -41,7 +41,7 @@
|
||||
_template:
|
||||
name: argocd-gitrepo-metacluster
|
||||
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) }}"
|
||||
notify:
|
||||
- Apply manifests
|
||||
@ -49,14 +49,19 @@
|
||||
- name: Create applicationset
|
||||
ansible.builtin.template:
|
||||
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
|
||||
group: root
|
||||
mode: 0600
|
||||
vars:
|
||||
_template:
|
||||
name: argocd-applicationset-metacluster
|
||||
namespace: argo-cd
|
||||
application:
|
||||
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:
|
||||
- Apply manifests
|
||||
|
||||
|
@ -137,9 +137,9 @@
|
||||
chdir: /opt/metacluster/cluster-api
|
||||
register: clusterctl_newcluster
|
||||
|
||||
- name: Initialize tempfile
|
||||
- name: Initialize tempfolder
|
||||
ansible.builtin.tempfile:
|
||||
state: file
|
||||
state: directory
|
||||
register: capi_clustermanifest
|
||||
|
||||
- name: Save workload cluster manifest
|
||||
@ -152,7 +152,7 @@
|
||||
cmd: >-
|
||||
kubectl slice \
|
||||
-f {{ capi_clustermanifest.path }} \
|
||||
-o /opt/metacluster/cluster-api/new-cluster
|
||||
-o {{ capi_clustermanifest.path }}/manifests
|
||||
|
||||
- name: Initialize/Push git repository
|
||||
ansible.builtin.shell:
|
||||
@ -161,17 +161,18 @@
|
||||
git config --global user.email "administrator@{{ vapp['metacluster.fqdn'] }}"
|
||||
git config --global user.name "administrator"
|
||||
git checkout -b main
|
||||
git add .
|
||||
git add ./manifests
|
||||
git commit -m "Upload manifests"
|
||||
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
|
||||
chdir: /opt/metacluster/cluster-api/new-cluster
|
||||
chdir: "{{ capi_clustermanifest.path }}"
|
||||
|
||||
- name: Cleanup tempfile
|
||||
ansible.builtin.file:
|
||||
path: "{{ capi_clustermanifest.path }}"
|
||||
state: absent
|
||||
when: capi_clustermanifest.path is defined
|
||||
# Temporarily disabled until manifests are properly managed by gitops
|
||||
# - name: Cleanup tempfolder
|
||||
# ansible.builtin.file:
|
||||
# path: "{{ capi_clustermanifest.path }}"
|
||||
# state: absent
|
||||
# when: capi_clustermanifest.path is defined
|
||||
|
||||
- name: Create in-cluster IpPool
|
||||
kubernetes.core.k8s:
|
||||
|
@ -53,6 +53,45 @@
|
||||
url: https://{{ vapp['workloadcluster.vip'] }}:6443
|
||||
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:
|
||||
_template:
|
||||
account:
|
||||
|
Reference in New Issue
Block a user