mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2026-10-23 20:22:03 +02:00
- Read the MetalLB speaker tag check from the managed host with slurp instead of a controller-side file lookup, and match the full image reference - Restore the tigera-operator namespace on the Calico operator Deployment wait while keeping the managed CRD waits cluster-scoped - Make Molecule verify inputs durable and scenario-specific via a per-scenario verify-vars.yml, driven by explicit verify_cni/verify_lb values instead of non-persisted converge facts - Rename the kube-vip multi-peer BGP env var from bgppeers to bgp_peers and vip_cidr to vip_subnet so v1.2.2 actually reads them - Map the legacy Cilium routed mode to tunnel and stop passing the alias directly to the chart - Use return-code based failed_when on apply and preflight commands so non-error failures are no longer treated as success - Clarify the sequential K3s upgrade path and backups in the README - Add kube-vip and MetalLB regression tests and a Cilium mode mapping unit
85 lines
3.1 KiB
YAML
85 lines
3.1 KiB
YAML
---
|
|
- name: Deploy example
|
|
block:
|
|
- name: "Create namespace: {{ testing_namespace }}"
|
|
kubernetes.core.k8s:
|
|
api_version: v1
|
|
kind: Namespace
|
|
name: "{{ testing_namespace }}"
|
|
state: present
|
|
wait: true
|
|
kubeconfig: "{{ kubecfg_path }}"
|
|
|
|
- name: Apply example manifests
|
|
kubernetes.core.k8s:
|
|
src: "{{ example_manifests_path }}/{{ item }}"
|
|
namespace: "{{ testing_namespace }}"
|
|
state: present
|
|
wait: true
|
|
kubeconfig: "{{ kubecfg_path }}"
|
|
with_items:
|
|
- deployment.yml
|
|
- service.yml
|
|
|
|
- name: Get info about nginx service
|
|
kubernetes.core.k8s_info:
|
|
kind: service
|
|
name: nginx
|
|
namespace: "{{ testing_namespace }}"
|
|
kubeconfig: "{{ kubecfg_path }}"
|
|
vars:
|
|
metallb_ip: status.loadBalancer.ingress[0].ip
|
|
metallb_port: spec.ports[0].port
|
|
register: nginx_services
|
|
|
|
- name: Assert that the nginx welcome page is available
|
|
ansible.builtin.uri:
|
|
url: http://{{ ip | ansible.utils.ipwrap }}:{{ port_ }}/
|
|
return_content: true
|
|
register: result
|
|
failed_when: "'Welcome to nginx!' not in result.content"
|
|
vars:
|
|
ip: >-
|
|
{{ nginx_services.resources[0].status.loadBalancer.ingress[0].ip }}
|
|
port_: >-
|
|
{{ nginx_services.resources[0].spec.ports[0].port }}
|
|
|
|
- name: Assert that the load balancer address is within the configured pool
|
|
ansible.builtin.assert:
|
|
that: lb_addr_in_range
|
|
success_msg: "LoadBalancer address {{ ip_value }} is in the configured range"
|
|
fail_msg: >-
|
|
LoadBalancer address {{ ip_value }} is not in the configured
|
|
range {{ verify_lb_ip_range }}
|
|
vars:
|
|
ip_value: >-
|
|
{{ nginx_services.resources[0].status.loadBalancer.ingress[0].ip }}
|
|
lb_first: "{{ verify_lb_ip_range[0] | default('') }}"
|
|
lb_is_range: "{{ '-' in lb_first and '/' not in lb_first }}"
|
|
lb_start: "{{ lb_first.split('-')[0] | default(ip_value) }}"
|
|
lb_end: "{{ lb_first.split('-')[1] | default(ip_value) }}"
|
|
# Strict membership is checked only when the first range entry is a
|
|
# start-end pair. CIDR entries (used by the ipv6 scenario) fall back to
|
|
# the reachability probe above.
|
|
lb_addr_in_range: >-
|
|
{{
|
|
(verify_lb_ip_range | length > 0) and
|
|
((not lb_is_range) or (
|
|
(ip_value | ansible.utils.ipaddr('int') >= lb_start | ansible.utils.ipaddr('int')) and
|
|
(ip_value | ansible.utils.ipaddr('int') <= lb_end | ansible.utils.ipaddr('int'))
|
|
))
|
|
}}
|
|
# Deactivated linter rules:
|
|
# - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap
|
|
# would be undefined. This will not be the case during playbook execution.
|
|
# noqa jinja[invalid]
|
|
|
|
always:
|
|
- name: "Remove namespace: {{ testing_namespace }}"
|
|
kubernetes.core.k8s:
|
|
api_version: v1
|
|
kind: Namespace
|
|
name: "{{ testing_namespace }}"
|
|
state: absent
|
|
kubeconfig: "{{ kubecfg_path }}"
|