Skip to content

Conversation

@adf-patrickha
Copy link

Currently both k3s_server and k3s_agent roles will fail when you follow the instructions from the README, as some tasks are dependent on optional variables that might not be set.

Changes

  • k3s_version: Use default(omit) when no version is specified
  • Fix template roles/k3s_server/templates/k3s.service.j2, making opts_tls_san and extra_server_args optional
  • Create k3s.service.env file when setting K3S_TOKEN, if the file is missing at that point

If these values are not provided, this task will fail as the variables are
missing and are not defined in a task beforehand.

Signed-off-by: Patrick Hasler <[email protected]>
Task will fail if no k3s_version is provided. But I'm actually not sure
if this will even work, as `default(omit)` will set
`INSTALL_K3S_VERSION` to an empty string.

Signed-off-by: Patrick Hasler <[email protected]>
Use `create:` parameter of `ansible.builtin.lineinfile` to create file
when it's missing. Otherwise the task will fail if file does not exist,
which breaks the fetch token mechanism.

Signed-off-by: Patrick Hasler <[email protected]>
@adf-patrickha adf-patrickha force-pushed the fix/undefined_variables branch from e55f369 to 80a132f Compare October 13, 2025 13:58
@adf-patrickha
Copy link
Author

Ping @dereknola for review (Cannot assign it on my own apparently).

Copy link
Member

@dereknola dereknola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should never NOT be a k3s.service.env. This is the 4 or 5th attempt by people trying to fix something that is not broken. As pointed out in:
#424
#425
#368

The k3s install script is responsible for creating those files. If the file is missing, then something has gone wrong with your installation.

The README is not intended to be a complete guide. The k3s_version variable is not optional, and that is laid out in the inventory sample

Finally, the opt_tls_san is defined as a blank string, so its inclusion is not a problem generally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants