k3s-io / k3s-ansible

Apache License 2.0
1.89k stars 780 forks source link

prereq fails at ufw step #306

Closed wkongucd closed 3 months ago

wkongucd commented 3 months ago

Hi, I'm not sure if this an ansible bug or this is a playbook bug. I ran this ansible playbook on Ubuntu 22.04.4 LTS and targeting a raspberry pi 4 "Debian GNU/Linux 12 (bookworm)" and raspberry pi 3 "Debian GNU/Linux 11 (bullseye)"

ufw is not enabled on my two nodes so it should skip all the ufw steps in the playbook, but it is erroring on the "TASK [prereq : If ufw enabled, allow default CIDRs]" step. Not sure why Ansible is trying to invoke the 'loop' instruction when ufw_status should not be defined. I'm still new to ansible, but I'm thinking this is an Ansible bug. If not, please advise if this prereq role can be fixed:

Here's the results when I run the ansible-playbook:

`ansible-playbook playbook/site.yml -i inventory.yml

PLAY [Cluster prep] ****

TASK [Gathering Facts] ***** ok: [10.0.20.229] ok: [10.0.20.201]

TASK [prereq : Install Dependent Ubuntu Packages] ** skipping: [10.0.20.201] skipping: [10.0.20.229]

TASK [prereq : Enable IPv4 forwarding] ***** ok: [10.0.20.201] ok: [10.0.20.229]

TASK [prereq : Enable IPv6 forwarding] ***** ok: [10.0.20.229] ok: [10.0.20.201]

TASK [prereq : Populate service facts] ***** ok: [10.0.20.201] ok: [10.0.20.229]

TASK [prereq : Get ufw status] ***** skipping: [10.0.20.201] skipping: [10.0.20.229]

TASK [prereq : If ufw enabled, open api port] ** skipping: [10.0.20.201] skipping: [10.0.20.229]

TASK [prereq : If ufw enabled, open etcd ports] **** skipping: [10.0.20.201] skipping: [10.0.20.229]

TASK [prereq : If ufw enabled, allow default CIDRs] **** fatal: [10.0.20.201]: FAILED! => {"msg": "template error while templating string: No filter named 'split'.. String: {{ (cluster_cidr + ',' + service_cidr) | split(',') }}"} fatal: [10.0.20.229]: FAILED! => {"msg": "template error while templating string: No filter named 'split'.. String: {{ (cluster_cidr + ',' + service_cidr) | split(',') }}"}

PLAY RECAP ***** 10.0.20.201 : ok=4 changed=0 unreachable=0 failed=1 skipped=4 rescued=0 ignored=0 10.0.20.229 : ok=4 changed=0 unreachable=0 failed=1 skipped=4 rescued=0 ignored=0 `

dereknola commented 3 months ago

What version of ansible are you running? Its possible https://github.com/k3s-io/k3s-ansible/pull/293 broke something.

wkongucd commented 3 months ago

I'm using the following ansible version:

ansible 2.10.8 config file = None configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3/dist-packages/ansible executable location = /usr/bin/ansible python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

dereknola commented 3 months ago

You should upgrade your ansible to 2.15.0+, we have seen several errors around using older versions. I was unable to replicate this error on a ubuntu 22.04 host and ubuntu target.