72 lines
2.2 KiB
YAML
72 lines
2.2 KiB
YAML
- name: Check if already installed in cluster
|
|
command: "cilium status"
|
|
register: cilium_status
|
|
ignore_errors: true
|
|
changed_when: false
|
|
check_mode: false
|
|
run_once: true
|
|
|
|
- name: Check if the Cilium CLI is installed
|
|
stat:
|
|
path: /usr/local/bin/cilium
|
|
register: cilium_cli
|
|
|
|
- name: Get Cilium CLI version
|
|
ansible.builtin.command:
|
|
argv:
|
|
- curl
|
|
- -s
|
|
- https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt
|
|
register: cilium_cli_version
|
|
check_mode: no
|
|
changed_when: false
|
|
run_once: true
|
|
|
|
- name: Determine CLI architecture
|
|
set_fact:
|
|
cli_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"
|
|
run_once: true
|
|
|
|
- name: Download and verify Cilium CLI
|
|
block:
|
|
- name: Download Cilium CLI tar.gz file
|
|
get_url:
|
|
url: "https://github.com/cilium/cilium-cli/releases/download/{{ cilium_cli_version.stdout }}/cilium-linux-{{ cli_arch }}.tar.gz"
|
|
dest: "/tmp/cilium-linux-{{ cli_arch }}.tar.gz"
|
|
checksum: "sha256:{{ lookup('url', 'https://github.com/cilium/cilium-cli/releases/download/' + cilium_cli_version.stdout + '/cilium-linux-' + cli_arch + '.tar.gz.sha256sum', wantlist=True)[0].split(' ')[0] }}"
|
|
mode: '0755'
|
|
|
|
- name: Extract Cilium CLI tar.gz to /usr/local/bin
|
|
unarchive:
|
|
src: "/tmp/cilium-linux-{{ cli_arch }}.tar.gz"
|
|
dest: "/usr/local/bin"
|
|
remote_src: yes
|
|
#extra_opts: ["--strip-components=1"]
|
|
mode: 777
|
|
# An installed CLI is left alone, not upgraded to the latest release
|
|
when: cilium_cli_version.stdout is defined and not cilium_cli.stat.exists
|
|
become: yes
|
|
|
|
- name: Clean up temporary files
|
|
file:
|
|
path: "/tmp/cilium-linux-{{ cli_arch }}.tar.gz"
|
|
state: absent
|
|
|
|
# Install cilium via cli
|
|
- block:
|
|
- name: Install cilium
|
|
command: >
|
|
cilium install
|
|
--set
|
|
imap.mode=kubernetes,
|
|
ipv6.enabled=true,
|
|
#ipam.operator.clusterPoolIPv4PodCIDRList={{ kubernetes.ipPool.ipv4.cluster_cidr }},
|
|
#ipam.operator.clusterPoolIPv6PodCIDRList={{ kubernetes.ipPool.ipv6.cluster_cidr }}
|
|
|
|
- name: Wait for cilium
|
|
command: cilium status --wait
|
|
changed_when: false
|
|
run_once: true
|
|
when:
|
|
- cilium_status.rc != 0
|