Ansible role to install CNI - Container Network Interface. CNI (Container Network Interface), a Cloud Native Computing Foundation project, consists of a specification and libraries for writing plugins to configure network interfaces in Linux containers, along with a number of supported plugins. CNI concerns itself only with network connectivity of containers and removing allocated resources when the container is deleted. Because of this focus, CNI has a wide range of support and the specification is simple to implement.
Change history:
See full CHANGELOG
Recent changes:
- update
cni_version
to1.6.1
- update
cni_version
to1.5.1
- add Ubuntu
24.04
support
# CNI plugin version
cni_version: "1.6.1"
# CNI binary directory
cni_bin_directory: "/opt/cni/bin"
# CNI configuration directory
cni_conf_directory: "/etc/cni/net.d"
# Directory to store the archive
cni_tmp_directory: "{{ lookup('env', 'TMPDIR') | default('/tmp', true) }}"
# Owner/group of "CNI" files/directories. If the variables are not set
# the resulting binary will be owned by the current user.
cni_owner: "root"
cni_group: "root"
# Specifies the permissions of the "CNI" binaries
cni_binary_mode: "0755"
# Operating system
# Possible options: "linux", "windows"
cni_os: "linux"
# Processor architecture "CNI" should run on.
# Other possible values: "arm", "arm64", "mips64le", "ppc64le", "s390x"
cni_arch: "amd64"
# Name of the archive file name
cni_archive: "cni-plugins-{{ cni_os }}-{{ cni_arch }}-v{{ cni_version }}.tgz"
# The CNI download URL (normally no need to change it)
cni_url: "https://github.com/containernetworking/plugins/releases/download/v{{ cni_version }}/{{ cni_archive }}"
# Restart "kubelet" service after "CNI" binaries or configuration have changed.
# This handler expects a systemd service called "kubelet.service".
cni_restart_kubelet: false
- Distribute CNI network configuration files (for Cilium this is not needed as CNI files are created by Cilium)
- hosts: your-host
roles:
- githubixx.cni
This role has a small test setup that is created using Molecule, libvirt (vagrant-libvirt) and QEMU/KVM. Please see my blog post Testing Ansible roles with Molecule, libvirt (vagrant-libvirt) and QEMU/KVM how to setup. The test configuration is here.
Afterwards molecule can be executed:
molecule converge
This will setup a few virtual machines (VM) with different supported Linux operating systems and installs CNI
.
To run a few tests:
molecule verify
To clean up run
molecule destroy
GNU GENERAL PUBLIC LICENSE Version 3