Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Improve reliability of ansible tasks #345

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/e2e/ansible/install_build_deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
name: "{{ build_pkgs[ansible_distribution | lower] }}"
state: present
- block:
- name: Download and extract Go tarball
- name: Download Go tarball
get_url:
url: https://go.dev/dl/go{{ go_version }}.linux-{{ target_arch }}.tar.gz
dest: /tmp/go{{ go_version }}.linux-{{ target_arch }}.tar.gz
retries: 3
delay: 10
- name: Extract Go tarball
unarchive:
# TODO: use facts
src: https://go.dev/dl/go{{ go_version }}.linux-{{ target_arch }}.tar.gz
src: /tmp/go{{ go_version }}.linux-{{ target_arch }}.tar.gz
creates: /usr/local/go
dest: /usr/local
remote_src: yes
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/ansible/install_containerd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
containerd config default > /etc/containerd/config.toml
args:
executable: /bin/bash
warn: false
- name: Restart containerd service
service:
name: containerd
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e/ansible/install_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,32 @@
- gnupg
- lsb-release
state: present
retries: 3
delay: 10
- name: Add docker repo GPG key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
keyring: /etc/apt/trusted.gpg.d/docker.gpg
state: present
retries: 3
delay: 10
- name: Add docker repo
apt_repository:
repo: "deb [arch={{ target_arch }} signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable"
filename: docker
update_cache: yes
state: present
retries: 3
delay: 10
- name: Install docker packages
package:
name:
- containerd.io
- docker-ce
- docker-ce-cli
state: present
retries: 3
delay: 10
- name: Create the docker group
group:
name: docker
Expand All @@ -54,28 +62,38 @@
- docker.io
- docker-buildx
state: present
retries: 3
delay: 10
- name: Create the docker group
group:
name: docker
state: present
retries: 3
delay: 10
when: docker_exist.rc != 0 and ansible_distribution == "Ubuntu" and ansible_distribution_version == "22.04"
- name: Handle docker installation on CentOS.
block:
- name: Install yum-utils
dnf:
name: yum-utils
state: present
retries: 3
delay: 10
- name: Add docker yum repo
shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
args:
creates: /etc/yum.repos.d/docker-ce.repo
retries: 3
delay: 10
- name: Install docker packages
dnf:
name:
- containerd.io
- docker-ce
- docker-ce-cli
state: present
retries: 3
delay: 10
when: docker_exist.rc != 0 and ansible_distribution == "CentOS"
#
# In order to prevent "systemd: docker.service Start request repeated too quickly"
Expand Down
18 changes: 16 additions & 2 deletions tests/e2e/ansible/install_kubeadm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,27 @@
file:
path: "{{ cni_home }}/bin"
state: directory
- name: Download CNI plugins
get_url:
url: "https://github.com/containernetworking/plugins/releases/download/{{ cni_version }}/cni-plugins-linux-{{ target_arch }}-{{ cni_version }}.tgz"
dest: /tmp/cni-plugins.tgz
retries: 3
delay: 10
- name: Install CNI plugins
unarchive:
# TODO: use facts
src: "https://github.com/containernetworking/plugins/releases/download/{{ cni_version }}/cni-plugins-linux-{{ target_arch }}-{{ cni_version }}.tgz"
src: /tmp/cni-plugins.tgz
dest: "{{ cni_home }}/bin"
remote_src: yes
- name: Download crictl
get_url:
url: "https://github.com/kubernetes-sigs/cri-tools/releases/download/{{ k8s_version }}/crictl-{{ k8s_version }}-linux-{{ target_arch }}.tar.gz"
dest: /tmp/crictl.tar.gz
retries: 3
delay: 10
- name: Install crictl
unarchive:
src: "https://github.com/kubernetes-sigs/cri-tools/releases/download/{{ k8s_version }}/crictl-{{ k8s_version }}-linux-{{ target_arch }}.tar.gz"
src: /tmp/crictl.tar.gz
creates: /usr/local/bin/crictl
dest: /usr/local/bin
remote_src: yes
Expand All @@ -46,6 +58,8 @@
url: https://storage.googleapis.com/kubernetes-release/release/{{ k8s_version }}/bin/linux/{{ target_arch }}/{{ item }}
dest: /usr/local/bin
mode: '+x'
retries: 3
delay: 10
with_items:
- kubeadm
- kubelet
Expand Down
19 changes: 16 additions & 3 deletions tests/e2e/ansible/install_test_deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
package:
name: "{{ test_pkgs[ansible_distribution | lower] }}"
state: present
retries: 3
delay: 10
# Install bats from source so that we get the latest features.
- name: Install bats from sources
block:
Expand All @@ -20,6 +22,8 @@
repo: https://github.com/bats-core/bats-core.git
dest: bats-core
force: yes
retries: 3
delay: 10
- name: Install bats
shell:
cmd: ./install.sh /usr/local
Expand All @@ -35,16 +39,25 @@
ignore_errors: yes
- name: Install kustomize
shell: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
curl -s --retry 3 --retry-delay 10 "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
cp -f ./kustomize /usr/local/bin
args:
creates: /usr/local/bin/kustomize
warn: false
retries: 3
delay: 10
when: kustomize_exist.rc != 0
- block:
- name: Download and extract Go tarball
- name: Download Go tarball
get_url:
url: https://go.dev/dl/go{{ go_version }}.linux-{{ target_arch }}.tar.gz
dest: /tmp/go{{ go_version }}.linux-{{ target_arch }}.tar.gz
retries: 3
delay: 10
- name: Extract Go tarball
unarchive:
# TODO: use facts
src: https://go.dev/dl/go{{ go_version }}.linux-{{ target_arch }}.tar.gz
src: /tmp/go{{ go_version }}.linux-{{ target_arch }}.tar.gz
creates: /usr/local/go
dest: /usr/local
remote_src: yes
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/ansible/start_docker_registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# TODO: this is ubuntu specific...
name: python3-pip
state: present
retries: 3
delay: 10
# The docker pip is needed by the docker_container ansible module itself.
- name: Install docker pip
pip:
Expand All @@ -30,6 +32,8 @@
if [ "$version_ge" = "2.29.0" ]; then
pip3 install requests==2.28.1
fi
retries: 3
delay: 10
- name: Start a docker registry
docker_container:
name: "{{ local_registry_name }}"
Expand All @@ -38,6 +42,8 @@
ports:
- "{{ local_registry_port }}:{{ local_registry_port }}"
state: started
retries: 3
delay: 10
#
# Remove the docker registry container.
#
Expand Down
Loading