githubixx.cni
ansible-role-cni
This is an Ansible role designed to install the CNI - Container Network Interface. CNI (Container Network Interface) is a project by the Cloud Native Computing Foundation. It provides a set of instructions and libraries for creating plugins that manage network connections in Linux containers, along with several existing plugins. CNI focuses solely on connecting containers to networks and releasing resources when the container is removed. This focused approach gives CNI broad support and makes it easy to use.
Changelog
Change history:
For complete details, check the CHANGELOG.
Recent changes:
Version 0.7.0+1.4.0
- Added support for Ubuntu
24.04
.
Version 0.6.0+1.4.0
- Updated CNI version to
1.4.0
.
Version 0.5.1+1.3.0
- Changed unarchive directory settings.
- Added a subdirectory to the
cni_tmp_directory
to prevent permission issues in the parent directory.
Version 0.5.0+1.3.0
- Updated CNI version to
1.3.0
. - Added a verification step in Molecule.
- Removed support for Ubuntu
18.04
(out of support). - Added support for Ubuntu
22.04
. - Included
dummy
andtap
CNI binaries. - Renamed Molecule scenario from
kvm
todefault
and adjusted memory and CPU options.
Role Variables
# CNI plugin version
cni_version: "1.4.0"
# Directory for CNI binaries
cni_bin_directory: "/opt/cni/bin"
# Directory for CNI configurations
cni_conf_directory: "/etc/cni/net.d"
# Temporary directory for archives
cni_tmp_directory: "{{ lookup('env', 'TMPDIR') | default('/tmp', true) }}"
# Owner/group for CNI files/directories
cni_owner: "root"
cni_group: "root"
# Permissions for CNI binaries
cni_binary_mode: "0755"
# Operating System support
cni_os: "linux"
# Processor architecture for CNI
cni_arch: "amd64"
# Archive file name
cni_archive: "cni-plugins-{{ cni_os }}-{{ cni_arch }}-v{{ cni_version }}.tgz"
# Download URL for CNI
cni_url: "https://github.com/containernetworking/plugins/releases/download/v{{ cni_version }}/{{ cni_archive }}"
# Restart kubelet service after changes
cni_restart_kubelet: false
TODO
- Set up CNI network configuration files (Note: for Cilium, this step isn't necessary as Cilium will create the CNI files).
Example Playbook
- hosts: your-host
roles:
- githubixx.cni
Testing
This role includes a basic testing setup using Molecule, libvirt (vagrant-libvirt), and QEMU/KVM. For setup instructions, please refer to my blog post Testing Ansible roles with Molecule, libvirt (vagrant-libvirt) and QEMU/KVM. The test configuration can be found here.
To execute molecule, run:
molecule converge
This command will create several virtual machines (VMs) with various supported Linux operating systems and install CNI
.
To perform tests, use:
molecule verify
To clean up, run:
molecule destroy
License
This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
Author Information
More information can be found at http://www.tauceti.blog.
Ansible role to install CNI (Container Network Interface)
ansible-galaxy install githubixx.cni