there are many possible locations where you could define it. Are you aware that there is a difference between “roles” and “playbooks”? The filelayout you created is a role- layout. A role contains a set of tasks which are applied to a host. The decision which host the role is running on is already made. So every variable you define in inside the role is available to that host.
So, you could define the variable inside the defaults/main.yml (least precedence), in the vars/main.yml or directly in the task.
Yes, I think I understand the difference between a role and a playbook - but it’s all still a bit hazy - I have been probably doing super bad practice (incorporating variables into an inventory file) recently, so I really trying to do it properly!