It seems, that systemddir isn't predefined: How should I extend following Ansibe…
- User
It seems, that systemd_dir isn't predefined: How should I extend following Ansibe playbook, if it should work for Debian and Redhat OS family?
- name: Write K3s service file ansible.builtin.template: src: "k3s-server.service.j2" dest: "{{ systemd_dir }}/k3s-server.service" owner: root group: root mode: "0644" register: _k3s_service
Assistant
systemd_diris not a built-in Ansible fact, so you have to set it yourself.
The canonical location is/etc/systemd/systemon every modern Linux distribution, but you can still make the playbook explicit for both Debian and Red Hat families.Add a small “bootstrap” task that defines the variable once, then use it everywhere else.
- name: Determine systemd unit directory ansible.builtin.set_fact: systemd_dir: /etc/systemd/system - name: Write K3s service file ansible.builtin.template: src: k3s-server.service.j2 dest: "{{ systemd_dir }}/k3s-server.service" owner: root group: root mode: "0644" register: _k3s_service
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.