Skip to content

Commit

Permalink
Split root tasks and API tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaassssiiee committed Jan 10, 2025
1 parent f6f279a commit 18aaa14
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 20 deletions.
16 changes: 12 additions & 4 deletions kubeblocks.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#!/usr/bin/env ansible-playbook
---
# ~/.kube/config should be valid
- name: Manage KubeBlocks
- name: Manage kbcli
hosts: controller
become: true
tasks:
- name: Configure KubeBlocks
ansible.builtin.include_role:
name: clusterlust.kbcli

- name: Manage KubeBlocks
hosts: localhost
become: false
connection: local
vars:
# Semaphore does not pass $HOME so K8S_AUTH_KUBECONFIG needs to be set.
k8s_auth_kubeconfig: /home/semaphore/.kube/config
# To use KubeBlocks addons set this Boolean
#use_kb_addons: true
# To manage KubeBlocks addons set this Boolean
# use_kb_addons: true
tasks:
- name: Configure KubeBlocks
ansible.builtin.include_role:
Expand Down
5 changes: 5 additions & 0 deletions roles/clusterlust.kbcli/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# kbcli
kbcli_releases_url: 'https://api.github.com/repos/apecloud/kbcli/releases/latest'
kbcli_repo_url: 'https://github.com/apecloud/kbcli/releases/download'
use_kbcli: true
desired_state: present
7 changes: 7 additions & 0 deletions roles/clusterlust.kbcli/tasks/absent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

- name: Remove kbcli
when: use_kbcli | bool
ansible.builtin.package:
name: kbcli
state: absent
File renamed without changes.
4 changes: 4 additions & 0 deletions roles/clusterlust.kbcli/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# desired_state in ['absent', 'present']
- name: "Converge state - {{ desired_state }}"
ansible.builtin.include_tasks: "{{ desired_state }}.yml"
5 changes: 5 additions & 0 deletions roles/clusterlust.kbcli/tasks/present.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

- name: Install kbcli
when: use_kbcli | bool
ansible.builtin.include_tasks: "kbcli.yml"
7 changes: 1 addition & 6 deletions roles/clusterlust.kubeblocks/tasks/absent.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
---
# when: desired_state == 'absent'
- name: Remove KubeBlocks
when: use_kubeblocks | bool
ansible.builtin.include_tasks: "kubeblocks.yml"

- name: Remove kbcli
when: use_kbcli | bool
ansible.builtin.package:
name: kbcli
state: absent
3 changes: 1 addition & 2 deletions roles/clusterlust.kubeblocks/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
# Main tasks entry point for the role

# desired_state in ['absent', 'present']
- name: "Converge state - {{ desired_state }}"
ansible.builtin.include_tasks: "{{ desired_state }}.yml"

Expand Down
8 changes: 0 additions & 8 deletions roles/clusterlust.kubeblocks/tasks/present.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
---
# when: desired_state == 'present'

# Works
- name: Install kbcli
when: use_kbcli | bool
ansible.builtin.include_tasks: "kbcli.yml"

# Works
- name: Install KubeBlocks
when: use_kubeblocks | bool
ansible.builtin.include_tasks: "kubeblocks.yml"

# This needs more development
- name: Manage KubeBlocks Add-ons
when: use_kb_addons | bool
ansible.builtin.include_tasks: "addons.yml"
Expand Down

0 comments on commit 18aaa14

Please sign in to comment.