фикс ошибок линта и молекулы

This commit is contained in:
Sergey Antropoff
2026-04-27 08:40:08 +03:00
parent 91299fcc1b
commit d9bc3c0bad
122 changed files with 3997 additions and 179 deletions

View File

@@ -17,3 +17,11 @@ rpi_cgroup_enable: true
rpi_cmdline_path: /boot/cmdline.txt
# For newer RPi OS (bookworm)
rpi_cmdline_path_new: /boot/firmware/cmdline.txt
# Common OS packages used across all nodes
k3s_common_packages:
- htop
- vim
- git
- jq
- net-tools

View File

@@ -8,6 +8,7 @@
k3s_token: "molecule-test-token-abc123"
k3s_version: "v1.29.3+k3s1"
k3s_become: true
k3s_master_ip: "127.0.0.1"
k3s_fetch_kubeconfig: false
k3s_node_labels: []
k3s_node_taints: []
@@ -19,6 +20,12 @@
k3s_install_dir: /usr/local/bin
k3s_config_dir: /etc/kubernetes/k3s
k3s_data_dir: /var/lib/kubernetes/k3s
k3s_common_packages:
- htop
- vim
- git
- jq
- net-tools
k3s_kubeconfig_path: /etc/kubernetes/k3s/k3s.yaml
k3s_disable_traefik: true
k3s_disable_servicelb: false

View File

@@ -18,11 +18,25 @@
ansible.builtin.raw: apt-get update && apt-get install -y python3
changed_when: true
- name: Install Ansible collections
- name: Check required Ansible collections
ansible.builtin.command: >
ansible-galaxy collection install
community.general ansible.posix --upgrade
ansible-galaxy collection list community.general ansible.posix
register: k3s_molecule_collections_check
changed_when: false
failed_when: false
become: false
delegate_to: localhost
run_once: true
- name: Install required Ansible collections when missing
ansible.builtin.command: >
ansible-galaxy collection install community.general ansible.posix
register: k3s_molecule_collections_install
until: k3s_molecule_collections_install.rc == 0
retries: 3
delay: 5
become: false
changed_when: true
delegate_to: localhost
run_once: true
when: k3s_molecule_collections_check.rc != 0

View File

@@ -29,6 +29,7 @@
ansible.builtin.command: swapoff -a
become: "{{ k3s_become }}"
changed_when: false
failed_when: false
- name: Remove swap from fstab
ansible.builtin.replace:
@@ -45,6 +46,7 @@
- overlay
- br_netfilter
become: "{{ k3s_become }}"
when: not (molecule_test | default(false) | bool)
- name: Persist kernel modules
ansible.builtin.copy:
@@ -54,6 +56,7 @@
br_netfilter
mode: '0644'
become: "{{ k3s_become }}"
when: not (molecule_test | default(false) | bool)
- name: Set sysctl params for Kubernetes networking
ansible.posix.sysctl:
@@ -67,6 +70,7 @@
- { key: "net.bridge.bridge-nf-call-ip6tables", value: "1" }
- { key: "net.ipv4.ip_forward", value: "1" }
become: "{{ k3s_become }}"
when: not (molecule_test | default(false) | bool)
- name: Create K3S config directory
ansible.builtin.file:

View File

@@ -18,19 +18,19 @@ data-dir: "{{ k3s_data_dir }}"
{% if k3s_etcd_type | default('embedded') == 'external' %}
# Внешний etcd кластер
datastore-endpoint: "{% for h in groups['etcd_nodes'] %}https://{{ hostvars[h]['ansible_host'] }}:2379{% if not loop.last %},{% endif %}{% endfor %}"
datastore-endpoint: "{% for h in groups['etcd_nodes'] %}https://{{ hostvars[h]['ansible_host'] | default(h) }}:2379{% if not loop.last %},{% endif %}{% endfor %}"
datastore-cafile: "{{ k3s_config_dir }}/etcd/ca.crt"
datastore-certfile: "{{ k3s_config_dir }}/etcd/client.crt"
datastore-keyfile: "{{ k3s_config_dir }}/etcd/client.key"
{% if inventory_hostname != groups['k3s_master'][0] or k3s_force_join | default(false) %}
server: "https://{{ k3s_join_address | default(hostvars[groups['k3s_master'][0]]['ansible_host']) }}:6443"
server: "https://{{ k3s_join_address | default(hostvars[groups['k3s_master'][0]]['ansible_host'] | default(groups['k3s_master'][0])) }}:6443"
{% endif %}
{% else %}
# HA embedded etcd: первый сервер инициализирует кластер, остальные присоединяются
{% if inventory_hostname == groups['k3s_master'][0] and not k3s_force_join | default(false) %}
cluster-init: true
{% else %}
server: "https://{{ k3s_join_address | default(hostvars[groups['k3s_master'][0]]['ansible_host']) }}:6443"
server: "https://{{ k3s_join_address | default(hostvars[groups['k3s_master'][0]]['ansible_host'] | default(groups['k3s_master'][0])) }}:6443"
{% endif %}
{% endif %}