49 lines
1.4 KiB
YAML
49 lines
1.4 KiB
YAML
---
|
|
- name: Flux CLI | Get latest version from GitHub
|
|
ansible.builtin.uri:
|
|
url: https://api.github.com/repos/fluxcd/flux2/releases/latest
|
|
return_content: true
|
|
register: _flux_latest
|
|
when: not flux_version
|
|
check_mode: false
|
|
|
|
- name: Flux CLI | Set version fact (latest)
|
|
ansible.builtin.set_fact:
|
|
_flux_version: "{{ _flux_latest.json.tag_name | regex_replace('^v', '') }}"
|
|
when: not flux_version
|
|
|
|
- name: Flux CLI | Set version fact (pinned)
|
|
ansible.builtin.set_fact:
|
|
_flux_version: "{{ flux_version | regex_replace('^v', '') }}"
|
|
when: flux_version
|
|
|
|
- name: Flux CLI | Download and unpack
|
|
ansible.builtin.unarchive:
|
|
src: "https://github.com/fluxcd/flux2/releases/download/v{{ _flux_version }}/flux_{{ _flux_version }}_linux_amd64.tar.gz"
|
|
dest: /usr/local/bin
|
|
remote_src: true
|
|
include:
|
|
- flux
|
|
creates: /usr/local/bin/flux
|
|
|
|
- name: Flux CLI | Set permissions
|
|
ansible.builtin.file:
|
|
path: /usr/local/bin/flux
|
|
mode: "0755"
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Flux CLI | Enable bash completion
|
|
ansible.builtin.shell: /usr/local/bin/flux completion bash > /etc/bash_completion.d/flux
|
|
args:
|
|
creates: /etc/bash_completion.d/flux
|
|
|
|
- name: Flux CLI | Verify pre-flight checks
|
|
ansible.builtin.command: flux check --pre
|
|
environment:
|
|
KUBECONFIG: "{{ flux_kubeconfig }}"
|
|
PATH: "/usr/local/bin:/usr/bin:/bin"
|
|
register: _flux_check
|
|
changed_when: false
|
|
failed_when: _flux_check.rc != 0
|