fix: use lists for cidr vars and node ip (#4)
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/test unknown status
ci/woodpecker/push/docs unknown status
ci/woodpecker/push/notify Pipeline failed

Reviewed-on: #4
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
Co-committed-by: Robert Kaussow <mail@thegeeklab.de>
This commit is contained in:
Robert Kaussow 2024-08-17 21:51:07 +02:00 committed by Robert Kaussow
parent d583082ffa
commit bc897a9322
4 changed files with 16 additions and 12 deletions

View File

@ -12,7 +12,8 @@ k3s_packages_extra: []
k3s_reset: False k3s_reset: False
k3s_token: "secure-token" k3s_token: "secure-token"
k3s_node_name: "{{ ansible_hostname }}" 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_init_log_enabled: False
k3s_selinux_enabled: False k3s_selinux_enabled: False
k3s_protect_kernel_defaults: False k3s_protect_kernel_defaults: False
@ -20,8 +21,10 @@ k3s_protect_kernel_defaults: False
k3s_server: True k3s_server: True
k3s_server_bind_ip: "0.0.0.0" k3s_server_bind_ip: "0.0.0.0"
k3s_server_cluster_domain: "cluster.local" k3s_server_cluster_domain: "cluster.local"
k3s_server_cluster_cidr: "10.42.0.0/16" k3s_server_cluster_cidr:
k3s_server_service_cidr: "10.43.0.0/16" - "10.42.0.0/16"
k3s_server_service_cidr:
- "10.43.0.0/16"
k3s_server_service_node_port_range: "30000-32767" k3s_server_service_node_port_range: "30000-32767"
k3s_server_cluster_dns: "10.43.0.10" k3s_server_cluster_dns: "10.43.0.10"
k3s_server_nodes: k3s_server_nodes:

View File

@ -50,7 +50,8 @@
pre_tasks: pre_tasks:
- name: Override host variables - name: Override host variables
ansible.builtin.set_fact: ansible.builtin.set_fact:
k3s_node_ip: "{{ ansible_default_ipv4.address }}" k3s_node_ip:
- "{{ ansible_default_ipv4.address }}"
roles: roles:
- role: xoxys.kernel - role: xoxys.kernel
- role: xoxys.k3s - role: xoxys.k3s

View File

@ -1,12 +1,12 @@
#jinja2: lstrip_blocks: True #jinja2: lstrip_blocks: True
--- ---
{% set __k3s_kube_apiserver_arg = lookup('template', '_internal/apiserver-arg.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_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_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_node_taint = lookup("template", "_internal/node-taint.yaml.j2") | from_yaml %}
token: "{{ k3s_token }}" token: "{{ k3s_token }}"
node-name: "{{ k3s_node_name }}" node-name: "{{ k3s_node_name }}"
node-ip: "{{ k3s_node_ip }}" node-ip: "{{ k3s_node_ip | join(',') }}"
{% if __k3s_node_taint is iterable %} {% if __k3s_node_taint is iterable %}
node-taint: node-taint:
{{ __k3s_node_taint | to_nice_yaml(indent=2) | indent(2, False) }} {{ __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 %} {% if k3s_server | bool %}
bind-address: "{{ k3s_server_bind_ip }}" bind-address: "{{ k3s_server_bind_ip }}"
cluster-domain: "{{ k3s_server_cluster_domain }}" 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 }}" 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 }}" service-node-port-range: "{{ k3s_server_service_node_port_range }}"
secrets-encryption: True secrets-encryption: True
write-kubeconfig: "{{ __k3s_config_dir }}/k3s.yaml" write-kubeconfig: "{{ __k3s_config_dir }}/k3s.yaml"

View File

@ -1,6 +1,6 @@
--- ---
__k3s_binary: /usr/local/bin/k3s __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: >- __k3s_server_init_args: >-
{% if k3s_server_nodes | length > 1 %} {% if k3s_server_nodes | length > 1 %}