PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
640 stars 135 forks source link

Create registries.yaml if k3s_registries.mirrors or k3s_registries.configs are not None #208

Closed matteyeux closed 1 year ago

matteyeux commented 1 year ago

Create registries.yaml if k3s_registries.mirrors or k3s_registries.configs are not None

Summary

The task Ensure containerd registries is run when k3s_registries is defined, but k3s_registries is always defined in defaults. This then creates a yaml file with null values for configs and mirrors :

root@deb11:~# cat /etc/rancher/k3s/registries.yaml 
---
configs: null
mirrors: null

It can be problematic if there is already a registries.yaml file present and it's overwritten by the role.

This MR adds a two conditions when importing the task. The task is imported only if k3s_registries.mirrors or k3s_registries.configs are not None. Both values are set to None by default.

Fixes #205

Issue type

Test instructions

If registries variable is not set (in the inventory or in a playbook) then the task Ensure containerd registries file exists is skipped and {{ k3s_config_dir }}/registries.yaml is not created.

Acceptance Criteria

Additional Information