diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 29b0a84..b2b3c8d 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -63,7 +63,7 @@ jobs: - name: Install Ansible and dependencies run: | - pip install ansible + pip install ansible netaddr ansible-galaxy collection install -r collections/requirements.yml - name: Verify Inventory @@ -295,7 +295,7 @@ jobs: - name: Install Ansible and dependencies run: | - pip install ansible + pip install ansible netaddr ansible-galaxy collection install -r collections/requirements.yml - name: Verify Inventory @@ -461,7 +461,7 @@ jobs: - name: Install Ansible and dependencies run: | - pip install ansible + pip install ansible netaddr ansible-galaxy collection install -r collections/requirements.yml - name: Verify Inventory @@ -531,7 +531,7 @@ jobs: - name: Install Ansible and dependencies run: | - pip install ansible + pip install ansible netaddr ansible-galaxy collection install -r collections/requirements.yml - name: Verify Inventory diff --git a/README.md b/README.md index fb546c4..c9bd45b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ on processor architectures: ## System requirements -The control node **must** have Ansible 8.0+ (ansible-core 2.15+) +The control node **must** have Ansible 8.0+ (ansible-core 2.15+) and the Python `netaddr` library (`pip install netaddr`), required by the `ansible.utils.ipwrap` filter for IPv6 `api_endpoint` support. All managed nodes in inventory must have: - Passwordless SSH access diff --git a/collections/requirements.yml b/collections/requirements.yml index 9dbb90c..4e82d9b 100644 --- a/collections/requirements.yml +++ b/collections/requirements.yml @@ -2,3 +2,4 @@ collections: - name: community.general - name: ansible.posix + - name: ansible.utils diff --git a/roles/k3s_agent/tasks/main.yml b/roles/k3s_agent/tasks/main.yml index 892d593..985269e 100644 --- a/roles/k3s_agent/tasks/main.yml +++ b/roles/k3s_agent/tasks/main.yml @@ -43,7 +43,7 @@ INSTALL_K3S_SKIP_START: "true" INSTALL_K3S_SYSTEMD_DIR: "{{ systemd_dir }}" INSTALL_K3S_VERSION: "{{ k3s_version }}" - INSTALL_K3S_EXEC: "agent --server https://{{ api_endpoint }}:{{ api_port }} {{ extra_agent_args }}" + INSTALL_K3S_EXEC: "agent --server https://{{ api_endpoint | ansible.utils.ipwrap }}:{{ api_port }} {{ extra_agent_args }}" # We overrides the extra_install_envs with required keys from _base_envs on purpose _install_envs: "{{ extra_install_envs | default({}) | combine(_base_envs) }}" changed_when: true diff --git a/roles/k3s_server/tasks/main.yml b/roles/k3s_server/tasks/main.yml index d5fa962..afa4358 100644 --- a/roles/k3s_server/tasks/main.yml +++ b/roles/k3s_server/tasks/main.yml @@ -67,7 +67,7 @@ - name: Add server URL to server config for joining servers in HA-IC setup when: (groups[server_group] | length) > 1 and inventory_hostname != groups[server_group][0] and not use_external_database ansible.builtin.set_fact: - k3s_server_config: "{{ k3s_server_config | combine({'server': 'https://' + api_endpoint + ':' + api_port | string}) }}" + k3s_server_config: "{{ k3s_server_config | combine({'server': 'https://' + (api_endpoint | ansible.utils.ipwrap) + ':' + api_port | string}) }}" # If the user has provided additional server config, merge it with the generated config - name: Merge user server config with generated server config @@ -216,7 +216,7 @@ - name: Change server address in kubeconfig on control node ansible.builtin.shell: | - KUBECONFIG={{ kubeconfig }} kubectl config set-cluster default --server=https://{{ api_endpoint }}:{{ api_port }} + KUBECONFIG={{ kubeconfig }} kubectl config set-cluster default --server=https://{{ api_endpoint | ansible.utils.ipwrap }}:{{ api_port }} delegate_to: 127.0.0.1 become: false register: k3s_server_csa_result diff --git a/roles/k3s_upgrade/tasks/main.yml b/roles/k3s_upgrade/tasks/main.yml index a42868d..84e55b4 100644 --- a/roles/k3s_upgrade/tasks/main.yml +++ b/roles/k3s_upgrade/tasks/main.yml @@ -103,7 +103,7 @@ - name: Add server URL to server config for joining servers in HA-IC setup when: (groups[server_group] | length) > 1 and inventory_hostname != groups[server_group][0] and not use_external_database ansible.builtin.set_fact: - k3s_server_config: "{{ k3s_server_config | combine({'server': 'https://' + api_endpoint + ':' + api_port | string}) }}" + k3s_server_config: "{{ k3s_server_config | combine({'server': 'https://' + (api_endpoint | ansible.utils.ipwrap) + ':' + api_port | string}) }}" # If the user has provided additional server config, merge it with the generated config - name: Merge user server config with generated server config @@ -163,7 +163,7 @@ INSTALL_K3S_SKIP_START: "true" INSTALL_K3S_SYSTEMD_DIR: "{{ systemd_dir }}" INSTALL_K3S_VERSION: "{{ k3s_version }}" - INSTALL_K3S_EXEC: "agent --server https://{{ api_endpoint }}:{{ api_port }} {{ extra_agent_args }}" + INSTALL_K3S_EXEC: "agent --server https://{{ api_endpoint | ansible.utils.ipwrap }}:{{ api_port }} {{ extra_agent_args }}" K3S_TOKEN: "{{ token if token is defined else k3s_upgrade_old_server_token.stdout }}" # We overrides the extra_install_envs with required keys from _base_envs on purpose _install_envs: "{{ extra_install_envs | default({}) | combine(_base_envs) }}"