cni

Ansible role cni

Ansible role to install CNI (Container Network Interface).

GitHub Version Issues Pull Requests Downloads
github Version Issues PullRequests Ansible Role

Example Playbook

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
# Copyright (C) 2021 Robert Wimmer
# SPDX-License-Identifier: GPL-3.0-or-later

- hosts: all
  # remote_user: vagrant
  become: true
  gather_facts: true
  tasks:
    - block:
        - name: (Archlinux) Init pacman
          raw: |
            pacman-key --init
            pacman-key --populate archlinux
          changed_when: false
          ignore_errors: true

        - name: (Archlinux) Update pacman cache
          community.general.pacman:
            update_cache: yes
          changed_when: false
      when: ansible_distribution | lower == 'archlinux'

    - name: (Ubuntu) Update APT package cache
      ansible.builtin.apt:
        update_cache: "true"
        cache_valid_time: 3600
      when: ansible_distribution | lower == 'ubuntu'

- hosts: all
  # remote_user: vagrant
  become: true
  gather_facts: true
  tasks:
    - name: Include CNI role
      ansible.builtin.include_role:
        name: buluma.cni
      vars:
        cni_restart_kubelet: false

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  gather_facts: no
  become: yes

  roles:
    - role: buluma.bootstrap
    - role: buluma.epel
    - role: buluma.ca_certificates

Also see a full explanation and example on how to use these roles.

Role Variables

The default values for the variables are set in defaults/main.yml:

---

# CNI plugin version
cni_version: "1.0.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"

# Operarting 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

Requirements

State of used roles

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub Version
buluma.bootstrap Ansible Molecule Version
buluma.epel Ansible Molecule Version
buluma.ca_certificates Ansible Molecule Version

Context

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles:

dependencies

Compatibility

This role has been tested on these container images:

container tags
Archlinux all
Ubuntu bionic, focal

The minimum version of Ansible required is 2.12, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub

Changelog

Role History

License

Apache-2.0

Author Information

Shadow Walker

Install
ansible-galaxy install buluma/ansible-role-cni
GitHub repository
License
apache-2.0
Downloads
11
Owner
DevOps Engineer