Skip to content

Commit

Permalink
Improvements to the playbook. (#13)
Browse files Browse the repository at this point in the history
* Skip BPFFS installation when LSB is not available

CentOS does not come with LSB by default. This skips installation of BPFFS when the `ansible_lsb`
fact is not available.

This might not be 100% correct, but it's better than having support only for Ubuntu.

* Install Cilium repository when rendering the template

When attempting to render the helm chart template in a clean helm installation, the playbook fails
because the repository has not yet been installed. This makes sure the repository exists before
attempting to render the template.

Additionally, when there are no repositories installed in helm, the `helm repo list` command exists
with an error. In such cases, the playbook would also fail. Now, errors are ignored when listing the
available repositories and the install command is ran wether the repo command failed or the
repository is not yet available. When the `helm repo list` command throws an error not related to
the absence of repositories, the install command will most likely throw it too, so the play will
fail in such cases.

* Apply suggestions from code review

Co-authored-by: Robert Wimmer <[email protected]>

Co-authored-by: Robert Wimmer <[email protected]>
  • Loading branch information
tiagoblackcode and githubixx authored Feb 16, 2022
1 parent f25ccca commit 253a5af
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions tasks/delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
notify:
- reload systemd
when:
- ansible_lsb.release is defined
- ansible_lsb.release is version('20.04', '<')

- name: Delete namespace used by Cilium
Expand Down
17 changes: 17 additions & 0 deletions tasks/helm_repository.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Register if Cilium Helm repository is installed
command: helm search repo {{ cilium_repo_name }} -n {{ cilium_namespace }} --version ^{{ cilium_chart_version }} 2>/dev/null
register: cilium_repo_installed
changed_when: false
delegate_to: 127.0.0.1
run_once: true
ignore_errors: true

- name: Add cilium helm repository
command: helm repo add {{ cilium_repo_name }} {{ cilium_chart_url }}
changed_when: false
delegate_to: 127.0.0.1
run_once: true
when: |
cilium_repo_installed.failed or
cilium_repo_installed.stdout.find(cilium_repo_name) == -1
15 changes: 2 additions & 13 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,7 @@
delegate_to: 127.0.0.1
run_once: true

- name: Register if Cilium Helm repository is installed
command: helm search repo {{ cilium_chart_name }} -n {{ cilium_namespace }} --version ^{{ cilium_chart_version }}
register: cilium_repo_installed
changed_when: false
delegate_to: 127.0.0.1
run_once: true

- name: Add cilium helm repository
command: helm repo add {{ cilium_chart_name }} {{ cilium_chart_url }}
changed_when: false
delegate_to: 127.0.0.1
run_once: true
when: "cilium_repo_installed.stdout.find(cilium_chart_name) == -1"
- include_tasks: helm_repository.yml

- name: BPFFS handling for Ubuntu 18.04
block:
Expand All @@ -40,6 +28,7 @@
enabled: true
state: started
when:
- ansible_lsb.release is defined
- ansible_lsb.release is version('20.04', '<')

- name: Install Cilium etcd secrets in k8s
Expand Down
2 changes: 2 additions & 0 deletions tasks/template.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- include_tasks: repo.yml

- name: Render values
block:
- name: Create temporary file for Helm values
Expand Down

0 comments on commit 253a5af

Please sign in to comment.