The following issue can be reproduced by running the playbook then updating the hosts.ini with another node and running the playbook again. The original_token and original_server vars are defined as null on the first server since it does not have the token and server address set in the /etc/rancher/rke2/config.yaml. Ansible throws an error because you can't get the length of null. Remove length in both those tasks, and by default, the when statement will result as false since those vars return null. No need to get length in that statement.
The following issue can be reproduced by running the playbook then updating the hosts.ini with another node and running the playbook again. The
original_token
andoriginal_server
vars are defined asnull
on the first server since it does not have the token and server address set in the/etc/rancher/rke2/config.yaml
. Ansible throws an error because you can't get the length ofnull
. Remove length in both those tasks, and by default, the when statement will result as false since those vars returnnull
. No need to get length in that statement.