Skip to content

Commit 5ad7aba

Browse files
committed
Refactor 'fluxcd' -> fluxcli
1 parent 195b1b1 commit 5ad7aba

File tree

6 files changed

+80
-80
lines changed

6 files changed

+80
-80
lines changed

roles/fluxcd/tasks/main.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

roles/fluxcd/vars/main.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Ansible Role: FLUXCD
1+
# Ansible Role: FLUX-CLI
22

3-
Ansible Role for FLUXCD Installation.
3+
Ansible Role for FLUX-CLI Installation.
44

55
## Supported OS
66

@@ -13,9 +13,9 @@ Ansible Role for FLUXCD Installation.
1313
Install Collection `ansible-galaxy collections install kube_cloud.general`
1414

1515
```yaml
16-
- name: "FLUXCD::INSTALL - Ensure FLUXCD Installed and Configured"
16+
- name: "FLUX-CLI::INSTALL - Ensure FLUX-CLI Installed and Configured"
1717
ansible.builtin.include_role:
18-
name: kube_cloud.general.fluxcd
18+
name: kube_cloud.general.fluxcli
1919
vars:
2020
fluxcd_version: "2.7.5"
2121
```
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22

3-
# FLUX Version
4-
fluxcd_version: "2.7.5"
3+
# FLUX CLI Version
4+
fluxcli_version: "2.7.5"
55

6-
# FLUX Release
7-
fluxcd_release: "v{{ fluxcd_version }}"
6+
# FLUX CLI Release
7+
fluxcli_release: "v{{ fluxcli_version }}"
88

99
# OS Architecture
10-
fluxcd_os_architecture: >-
10+
fluxcli_os_architecture: >-
1111
{% if ansible_architecture == 'x86_64' %}
1212
amd64
1313
{% elif ansible_architecture == 'i386' %}

roles/fluxcli/tasks/main.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
3+
# Find installed FLUX-CLI Version
4+
- name: "FLUX-CLI::INSTALL - Get Flux CD version if installed"
5+
ansible.builtin.command: flux version --client
6+
register: fluxcli_version_output
7+
changed_when: false
8+
ignore_errors: true
9+
10+
# Define Flux CD Version as Variable if Installed
11+
- name: "FLUX-CLI::INSTALL - Define FLUX-CLI Version as Variable if Installed"
12+
ansible.builtin.set_fact:
13+
installed_fluxcli_version: "{{ fluxcli_version_output.stdout | regex_replace('^flux\\s*:\\s*v([0-9.]+).*', '\\1') | regex_replace('^v', '') }}"
14+
fluxcli_semantic_version: "{{ fluxcli_version.split('+')[0] | regex_replace('^v', '') }}"
15+
when: fluxcli_version_output.rc == 0
16+
17+
# Print Vars
18+
- name: "FLUX-CLI::INSTALL - Show Installed Version Result [({{ ansible_distribution }})]"
19+
ansible.builtin.debug:
20+
var: fluxcli_version_output
21+
22+
# Print Vars
23+
- name: "FLUX-CLI::INSTALL - Show Facts [({{ ansible_distribution }})]"
24+
ansible.builtin.debug:
25+
msg:
26+
- "FLUX-CLI Installed Version : {{ installed_fluxcli_version | default('') }}"
27+
- "FLUX-CLI Required Version : {{ fluxcli_semantic_version | default('') }}"
28+
- "FLUX-CLI Original Version : {{ fluxcli_version }}"
29+
30+
# Download and install FLUX-CLI if not yet installed
31+
- name: "FLUX-CLI::INSTALL - Installation Block [({{ ansible_distribution }})]"
32+
when:
33+
- fluxcli_version_output.rc != 0 or installed_fluxcli_version is version(fluxcli_semantic_version, '<')
34+
block:
35+
36+
# Create Required Directories
37+
- name: "FLUX-CLI::INSTALL - Ensure FLUX-CLI directories are created [({{ ansible_distribution }})]"
38+
ansible.builtin.file:
39+
path: "{{ item.path }}"
40+
state: directory
41+
mode: "{{ item.mode | default('u+rwx,g+rwx,o+x') }}"
42+
recurse: true
43+
loop:
44+
- { path: "{{ fluxcli_extraction_root_dir }}", mode: "u+rwx,g+rwx,o+rwx" }
45+
46+
# Download and Unarchive Flux CD
47+
- name: "FLUX-CLI::INSTALL - Download and Unarchive FLUX-CLI [({{ ansible_distribution }})]"
48+
ansible.builtin.unarchive:
49+
src: "{{ fluxcli_archive_url }}"
50+
dest: "{{ fluxcli_extraction_root_dir }}"
51+
remote_src: true
52+
53+
# Install Flux CD
54+
- name: "FLUX-CLI::INSTALL - Install FLUX-CLI [({{ ansible_distribution }})]"
55+
ansible.builtin.copy:
56+
src: "{{ fluxcli_extraction_root_dir }}/flux"
57+
dest: "{{ fluxcd_binary_path }}/flux"
58+
remote_src: true
59+
force: true
60+
backup: true
61+
mode: '0755'

roles/fluxcli/vars/main.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
# Archive URL
4+
fluxcli_download_url: "https://github.com/fluxcd/flux2/releases/download/{{ fluxcli_release }}/flux_{{ fluxcli_version }}_linux_{{ fluxcli_os_architecture }}.tar.gz"
5+
6+
# Extraction Directory
7+
fluxcli_extraction_root_dir: "/tmp/fluxcli"
8+
9+
# Flux Binary Path
10+
fluxcli_binary_path: "/usr/local/bin/flux"

0 commit comments

Comments
 (0)