diff --git a/defaults/main.yml b/defaults/main.yml index 85192ff..5d21739 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -12,7 +12,8 @@ k3s_packages_extra: [] k3s_reset: False k3s_token: "secure-token" k3s_node_name: "{{ ansible_hostname }}" -k3s_node_ip: "{{ ansible_default_ipv4.address }}" +k3s_node_ip: + - "{{ ansible_default_ipv4.address }}" k3s_init_log_enabled: False k3s_selinux_enabled: False k3s_protect_kernel_defaults: False @@ -20,8 +21,10 @@ k3s_protect_kernel_defaults: False k3s_server: True k3s_server_bind_ip: "0.0.0.0" k3s_server_cluster_domain: "cluster.local" -k3s_server_cluster_cidr: "10.42.0.0/16" -k3s_server_service_cidr: "10.43.0.0/16" +k3s_server_cluster_cidr: + - "10.42.0.0/16" +k3s_server_service_cidr: + - "10.43.0.0/16" k3s_server_service_node_port_range: "30000-32767" k3s_server_cluster_dns: "10.43.0.10" k3s_server_nodes: diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 1357b76..83bed33 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -50,7 +50,8 @@ pre_tasks: - name: Override host variables ansible.builtin.set_fact: - k3s_node_ip: "{{ ansible_default_ipv4.address }}" + k3s_node_ip: + - "{{ ansible_default_ipv4.address }}" roles: - role: xoxys.kernel - role: xoxys.k3s diff --git a/tasks/setup.yml b/tasks/setup.yml index fd5f1b8..0c3b7fe 100644 --- a/tasks/setup.yml +++ b/tasks/setup.yml @@ -67,7 +67,7 @@ state: patched definition: metadata: - labels: "{{ (__k3s_node_lables['control'] if k3s_server | bool else __k3s_node_lables['worker']) | combine(__k3s_node_lables['general'], k3s_node_labels) }}" + labels: "{{ (__k3s_node_lables['control'] if k3s_server | bool else __k3s_node_lables['worker']) | combine(__k3s_node_lables['general'], 66) }}" delegate_to: "{{ hostvars[k3s_server_nodes[0]]['inventory_hostname'] }}" - name: Patch existing resources diff --git a/templates/etc/rancher/k3s/config.yaml.j2 b/templates/etc/rancher/k3s/config.yaml.j2 index 8d7c528..d62b94d 100644 --- a/templates/etc/rancher/k3s/config.yaml.j2 +++ b/templates/etc/rancher/k3s/config.yaml.j2 @@ -1,12 +1,12 @@ #jinja2: lstrip_blocks: True --- -{% set __k3s_kube_apiserver_arg = lookup('template', '_internal/apiserver-arg.yaml.j2') | from_yaml %} -{% set __k3s_kube_controller_manager_arg = lookup('template', '_internal/kube-controller-manager-arg.yaml.j2') | from_yaml %} -{% set __k3s_kubelet_arg = lookup('template', '_internal/kubelet-arg.yaml.j2') | from_yaml %} -{% set __k3s_node_taint = lookup('template', '_internal/node-taint.yaml.j2') | from_yaml %} +{% set __k3s_kube_apiserver_arg = lookup("template", "_internal/apiserver-arg.yaml.j2") | from_yaml %} +{% set __k3s_kube_controller_manager_arg = lookup("template", "_internal/kube-controller-manager-arg.yaml.j2") | from_yaml %} +{% set __k3s_kubelet_arg = lookup("template", "_internal/kubelet-arg.yaml.j2") | from_yaml %} +{% set __k3s_node_taint = lookup("template", "_internal/node-taint.yaml.j2") | from_yaml %} token: "{{ k3s_token }}" node-name: "{{ k3s_node_name }}" -node-ip: "{{ k3s_node_ip }}" +node-ip: "{{ k3s_node_ip | join(',') }}" {% if __k3s_node_taint is iterable %} node-taint: {{ __k3s_node_taint | to_nice_yaml(indent=2) | indent(2, False) }} @@ -21,9 +21,9 @@ protect-kernel-defaults: {{ k3s_protect_kernel_defaults | bool | lower }} {% if k3s_server | bool %} bind-address: "{{ k3s_server_bind_ip }}" cluster-domain: "{{ k3s_server_cluster_domain }}" -cluster-cidr: "{{ k3s_server_cluster_cidr }}" +cluster-cidr: "{{ k3s_server_cluster_cidr | join(',') }}" cluster-dns: "{{ k3s_server_cluster_dns }}" -service-cidr: "{{ k3s_server_service_cidr }}" +service-cidr: "{{ k3s_server_service_cidr | join(',') }}" service-node-port-range: "{{ k3s_server_service_node_port_range }}" secrets-encryption: True write-kubeconfig: "{{ __k3s_config_dir }}/k3s.yaml" diff --git a/vars/main.yml b/vars/main.yml index 78003f7..52ae3f6 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,6 +1,6 @@ --- __k3s_binary: /usr/local/bin/k3s -__k3s_server_ip: "{{ hostvars[k3s_server_nodes[0]].k3s_node_ip }}" +__k3s_server_ip: "{{ hostvars[k3s_server_nodes[0]].k3s_node_ip | first }}" __k3s_server_init_args: >- {% if k3s_server_nodes | length > 1 %}