chore: Refactor git commands to git_acp module

This commit is contained in:
Danny Bessems 2023-08-23 14:31:09 +02:00
parent 3e3a92c344
commit eb2ada2164
2 changed files with 34 additions and 14 deletions

View File

@ -122,8 +122,8 @@
- organization: wl
body:
name: GitOps.Config
# auto_init: true
# default_branch: main
auto_init: true
default_branch: main
description: GitOps manifests
loop_control:
label: "{{ item.organization ~ '/' ~ item.body.name }}"

View File

@ -5,6 +5,12 @@
recurse: false
register: helm_charts
- name: Pull existing repository
ansible.builtin.git:
repo: https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
dest: /opt/workloadcluster/git-repositories/gitops
version: main
- name: Create hard-links to populate new git-repository
ansible.builtin.shell:
cmd: >-
@ -41,18 +47,32 @@
loop_control:
label: "{{ item.key }}"
- name: Initialize/Push git repository
ansible.builtin.shell:
cmd: |
git init
git config --global user.email "administrator@{{ vapp['metacluster.fqdn'] }}"
git config --global user.name "administrator"
git checkout -b main
git add .
git commit -m "Upload charts"
git remote add origin https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
git push https://administrator:{{ vapp['metacluster.password'] | urlencode }}@git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git --all
chdir: /opt/workloadcluster/git-repositories/gitops
- name: Push git repository
lvrfrc87.git_acp.git_acp:
path: /opt/workloadcluster/git-repositories/gitops
branch: main
comment: "Upload charts"
add:
- .
url: https://administrator:{{ vapp['metacluster.password'] | urlencode }}@git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
environment:
GIT_AUTHOR_NAME: administrator
GIT_AUTHOR_EMAIL: administrator@{{ vapp['metacluster.fqdn'] }}
GIT_COMMITTER_NAME: administrator
GIT_COMMITTER_EMAIL: administrator@{{ vapp['metacluster.fqdn'] }}
# - name: Initialize/Push git repository
# ansible.builtin.shell:
# cmd: |
# git init
# git config --global user.email "administrator@{{ vapp['metacluster.fqdn'] }}"
# git config --global user.name "administrator"
# git checkout -b main
# git add .
# git commit -m "Upload charts"
# git remote add origin https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
# git push https://administrator:{{ vapp['metacluster.password'] | urlencode }}@git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git --all
# chdir: /opt/workloadcluster/git-repositories/gitops
- name: Retrieve workload-cluster kubeconfig
kubernetes.core.k8s_info: