# CLD setup in Ansible playbook - name: Detect existing minikube installation tags: s4,cld ansible.builtin.command: minikube version failed_when: false # never failed even if the exit code is not zero register: minikube_presence # https://minikube.sigs.k8s.io/docs/start/ - name: Download latest Minikube RPM tags: s4,cld when: ansible_facts["os_family"] == 'RedHat' and minikube_presence.rc > 0 ansible.builtin.get_url: dest: /tmp/minikube-latest.x86_64.rpm url: https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm - name: Install Minikube RPM file tags: s4,cld when: ansible_facts["os_family"] == 'RedHat' and minikube_presence.rc > 0 become: true ansible.builtin.shell: rpm -Uvh /tmp/minikube-latest.x86_64.rpm - name: Download latest Minikube DEB tags: s4,cld when: ansible_facts["os_family"] == 'Debian' and minikube_presence.rc > 0 ansible.builtin.get_url: dest: /tmp/minikube_latest_amd64.deb url: https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb - name: Install Minikube DEB file tags: s4,cld when: ansible_facts["os_family"] == 'Debian' and minikube_presence.rc > 0 become: true ansible.builtin.shell: dpkg -i /tmp/minikube_latest_amd64.deb # Note: this task will prompt you a GUI password prompt for your sudo password # This also fails on missing virt/containers prerequesites - name: Run Minikube once to accelerate first startup later. This only runs in 'download only' mode tags: s4,cld register: minikube_first_pull ansible.builtin.shell: minikube start --download-only # Sadly the minikube start --download-only doesn't download the 1.9GB kicbase image... so we just do it ourself # This may be caused by this error # E0221 22:49:07.767041 1091 start.go:846] api.Load failed for minikube: filestore "minikube": Docker machine "minikube" does not exist. Use "docker-machine ls" to list machines. Use "docker-machine create" to add a new one. # With a small hack to pull the same version that listed in the previous output, to avoid hard-coding any tag value - name: "If Docker is present, pull additionnal image k8s-minikube/kicbase for Minikube" tags: s4,cld failed_when: false # just ignore docker missing in case another backend is used... ansible.builtin.shell: cmd: | set -o pipefail VERSION=$(echo "{{ minikube_first_pull.stdout }}" | grep "Pulling base image" | grep -oP "v\d+\.\d+\.\d+") echo docker pull gcr.io/k8s-minikube/kicbase:$VERSION - name: Install jq and yq via DNF tags: s4,cld become: true when: ansible_facts['os_family'] == "RedHat" ansible.builtin.dnf: name: - jq # JSON manipulator - yq # YAML manipulator - name: Install jq and yq via APT tags: s4,cld become: true when: ansible_facts['os_family'] == "Debian" ansible.builtin.apt: name: - jq # JSON manipulator - yq # YAML manipulator - name: Install Golang via DNF to compile Vegeta tags: s4,cld become: true when: ansible_facts['os_family'] == "RedHat" ansible.builtin.dnf: name: - golang # Note: apt install golang -> 1.22. Vegeta requires at least 1.24. - name: Install latest Golang version via SNAP to compile Vegeta when: ansible_facts['os_family'] == "Debian" tags: s4,cld become: true community.general.snap: classic: true name: - go # This fixes a bug if the toolchain is older. In case a student has installed gaps-cli with Golang the last semester when Go was at 1.22... # go: toolchain upgrade needed to resolve golang.org/x/net/http2 # go: golang.org/x/net@v0.50.0 requires go >= 1.24.0 (running go 1.22.2) # Sadly there is no state=latest like dnf, we have to update via a shell command... - name: Make sure SNAP version of Golang is up-to-date to have at least 1.24 for Vegeta tags: s4,cld become: true when: ansible_facts['os_family'] == "Debian" ansible.builtin.shell: snap refresh go - name: Compile Vegeta from Github repository tsenart/vegeta tags: s4,cld ansible.builtin.shell: go install github.com/tsenart/vegeta@latest args: creates: ~/go/bin/vegeta - name: Add ~/go/bin to Fish PATH tags: s4,cld ansible.builtin.shell: fish -c 'fish_add_path --append ~/go/bin || true' - name: Detect existing Terraform installation tags: s4,cld ansible.builtin.command: terraform --version failed_when: false # never failed even if the exit code is not zero register: terraform_presence # From https://developer.hashicorp.com/terraform/install?product_intent=terraform - name: Add RPM repository rpm.releases.hashicorp.com for Terraform tags: s4,cld become: true # all tasks are sudo when: ansible_facts['os_family'] == 'RedHat' and terraform_presence.rc > 0 ansible.builtin.shell: cmd: | dnf install -y dnf-plugins-core dnf config-manager addrepo --from-repofile=https://rpm.releases.hashicorp.com/fedora/hashicorp.repo args: creates: /etc/yum.repos.d/hashicorp.repo - name: Add DEB repository deb.releases.hashicorp.com for Terraform tags: s4,cld become: true # all tasks are sudo when: ansible_facts['os_family'] == 'Debian' and terraform_presence.rc > 0 ansible.builtin.shell: cmd: | wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list sudo apt update && sudo apt install terraform args: creates: /etc/apt/sources.list.d/hashicorp.list - name: Install Terraform via DNF tags: s4,cld become: true when: ansible_facts['os_family'] == "RedHat" ansible.builtin.dnf: name: - terraform - name: Install Terraform via APT tags: s4,cld become: true when: ansible_facts['os_family'] == "Debian" ansible.builtin.apt: name: - terraform # From https://cloud.google.com/sdk/docs/install#rpm - name: Add Google Cloud RPM registry on packages.cloud.google.com become: true when: ansible_facts['os_family'] == "RedHat" tags: s4,cld ansible.builtin.yum_repository: name: google-cloud-cli description: "Google Cloud registry" baseurl: "https://packages.cloud.google.com/yum/repos/cloud-sdk-el9-x86_64" gpgkey: "https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg" repo_gpgcheck: false gpgcheck: true - name: Add Google Cloud DEB registry on packages.cloud.google.com tags: s4,cld become: true when: ansible_facts['os_family'] == "Debian" ansible.builtin.shell: creates: /usr/share/keyrings/cloud.google.gpg cmd: | curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list - name: Install Google Cloud CLI (gcloud), kubectl and awscli2 via DNF tags: s4,cld become: true when: ansible_facts['os_family'] == "RedHat" ansible.builtin.dnf: name: - libxcrypt-compat.x86_64 # as required by the docs - google-cloud-cli - kubectl - awscli2 # this is the new version 2. (pip install awscli installs the version 1) - name: Install Google Cloud CLI (gcloud), kubectl and awscli2 via APT tags: s4,cld become: true when: ansible_facts['os_family'] == "Debian" ansible.builtin.apt: update_cache: true # run apt update before name: - google-cloud-cli - kubectl # https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html - name: Install latest AWS CLI v2 via Snap when: ansible_facts['os_family'] == "Debian" tags: s4,cld become: true community.general.snap: classic: true name: - aws-cli - name: Last check to ensure tools are installed tags: s4,cld ansible.builtin.shell: cmd: | aws --version gcloud --version minikube version ~/go/bin/vegeta --version terraform --version ansible --version jq --version yq --version