Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some file are not created (k3s.service.env, k3s-agent.service.env) #368

Open
jkrenzer opened this issue Oct 7, 2024 · 6 comments
Open

Comments

@jkrenzer
Copy link

jkrenzer commented Oct 7, 2024

Hi!

Due to the missing parameter create: true in the ansible.builtin.lineinfile command, some files are not created when they are empty and thus an installation from a clean system fails.

So far I identified following steps:

In roles/k3s_server/tasks/main.yaml:

  • Add service environment variables
  • Add token as an environment variable

In roles/k3s_agent/tasks/main.yaml:

  • Add the token for joining the cluster to the environment

Cheers,

Jörn

@dereknola
Copy link
Member

K3s-ansible is not responsible for creating the k3s.service.env file. That is created by the k3s install script. https://github.com/k3s-io/k3s/blob/master/install.sh#L961. What types of errors are you seeing?

@jkrenzer
Copy link
Author

jkrenzer commented Oct 8, 2024

First the errors were censored, when setting no_log: false in the aforementioned tasks it was a file not found error.

System is a freshly installed Debian 11/bullseye server, ansible collection is from the master branch here.

@sky003
Copy link

sky003 commented Oct 8, 2024

I probably have a similar issue. Perhaps it has something to do with this change bc03d1c

This file is not created {{ systemd_dir }}/k3s-agent.service.env. And I don't see where it's supposed to be created by k3s.

So probably as @jkrenzer offered, we should add create: true:

- name: Add the token for joining the cluster to the environment
  no_log: true # avoid logging the server token
  ansible.builtin.lineinfile:
    path: "{{ systemd_dir }}/k3s-agent.service.env"
    line: "{{ item }}"
    create: true
  with_items:
    - "K3S_TOKEN={{ token }}"

@dereknola
Copy link
Member

dereknola commented Oct 8, 2024

I'm still unable to reproduce this issue, I can clearly find the k3s-agent.service.env on a fresh installed ubuntu node:

root@agent-0:/home/vagrant# cat /etc/systemd/system/k3s-agent.service.env 
K3S_TOKEN=myvagrant

Both agent and server service and service.env files are created when the k3s install script runs on the nodes.

And I don't see where it's supposed to be created by k3s.

The creation line is linked above

@dereknola
Copy link
Member

What does your inventory.yaml look like, are you changing any of the k3s configuration?

@dereknola
Copy link
Member

Ah I think I found the problem. On debian 11, the install script is not getting downloaded correctly

TASK [k3s_agent : Download K3s install script] *********************************
fatal: [server-0]: FAILED! => {"changed": false, "cmd": "k3s --version", "msg": "[Errno 2] No such file or directory: b'k3s'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
...ignoring

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

No branches or pull requests

3 participants