The v3.0 provider is not yet available as a stable release in the OpenTofu/Terraform registry. Downgraded to v2.9 which is the latest stable version. Also fixed minor yamllint issues in flux.yml: - Added space after comment marker - Removed trailing blank line
52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
---
|
|
# 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: true
|
|
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
|