feat: Commit initial
This commit is contained in:
commit
40dc0f4184
43 changed files with 1990 additions and 0 deletions
47
ansible/roles/k3s-server/tasks/flux.yml
Normal file
47
ansible/roles/k3s-server/tasks/flux.yml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
# Install and configure FluxCD
|
||||
|
||||
- name: Check if flux is already installed
|
||||
command: k3s kubectl get namespace {{ flux_namespace }}
|
||||
register: flux_installed
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Download Flux CLI
|
||||
get_url:
|
||||
url: "https://github.com/fluxcd/flux2/releases/download/{{ flux_version }}/flux_{{ flux_version | replace('v', '') }}_linux_amd64.tar.gz"
|
||||
dest: /tmp/flux.tar.gz
|
||||
mode: '0644'
|
||||
when: flux_installed.rc != 0
|
||||
|
||||
- name: Extract Flux CLI
|
||||
unarchive:
|
||||
src: /tmp/flux.tar.gz
|
||||
dest: /usr/local/bin
|
||||
remote_src: yes
|
||||
creates: /usr/local/bin/flux
|
||||
when: flux_installed.rc != 0
|
||||
|
||||
- name: Install FluxCD in cluster
|
||||
shell: |
|
||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
/usr/local/bin/flux install --namespace={{ flux_namespace }}
|
||||
when: flux_installed.rc != 0
|
||||
register: flux_install_result
|
||||
changed_when: "'installed' in flux_install_result.stdout"
|
||||
|
||||
- name: Wait for FluxCD to be ready
|
||||
shell: |
|
||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
/usr/local/bin/flux check
|
||||
register: flux_check
|
||||
until: flux_check.rc == 0
|
||||
retries: 30
|
||||
delay: 10
|
||||
changed_when: false
|
||||
when: flux_installed.rc != 0
|
||||
|
||||
- name: Display FluxCD installation status
|
||||
debug:
|
||||
msg: "FluxCD installed successfully. Configure GitRepository in kubernetes/flux-system/"
|
||||
when: flux_installed.rc != 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue