Unit file nodered.service does not exist

I'm trying to deploy node-red automatically via ansible,

I got everything up to the point I want with installing node-red via the script provided at https://nodered.org/docs/getting-started/raspberrypi

But when I try to run the command:
sudo systemctl enable nodered.service

I get an error:
Failed to enable unit: Unit file nodered.service does not exist.

This errors on ansible side, and I have a deployed server with node-red installed, but not running.

My goal is to have node-red run after deploy and stay running (hopefully as a service as suggested by @knolleary )

Update: I'm trying to auto run this as the ubuntu user

Would anyone suggest I reimplement PM2 or stick with the services method?


No, stick with systemd. You have to download the service file and the other scripts, look at the Pi install script to see where they are.

Ok, I see I have node-red being installed via npm:
npm install -g --unsafe-perm node-red node-red-admin
One issue I had with installing node-red via ansible using the script was the prompting for Y / N, but I now see there are command line options to automate these. Will try that and see if the script can get everything I need, if so, it should be OK with the systemctl service creation.

I didn't mean to use the installation script, I meant to look there to see where the files you need are. This should do it

- name: Install node-red
  become: yes
    name: node-red
    global: yes
    unsafe_perm: yes
- name: Download scripts
  become: yes
    owner: root
    mode: '755'
    url: "https://raw.githubusercontent.com/node-red/linux-installers/master/resources/{{ item }}"
    dest: "/usr/bin/{{ item|basename }}"
    - node-red-start
    - node-red-stop
    - node-red-restart
    - node-red-reload
    - node-red-log
- name: check if nodered.service exists
    path: /lib/systemd/system/nodered.service
  register: nodered_service
- name: Download nodered.service
  become: yes
    owner: root
    mode: '644'
    force: no
    url: "https://raw.githubusercontent.com/node-red/linux-installers/master/resources/nodered.service"
    dest: "/lib/systemd/system/nodered.service"
  when: nodered_service.stat.exists == False
- name: Configure user in nodered.service
  become: yes
    - name: user
        path: /lib/systemd/system/nodered.service
        regexp: 'User='
        line: "User={{ansible_env.USER}}"
    - name: group
        path: /lib/systemd/system/nodered.service
        regexp: 'Group='
        line: "Group={{ansible_env.USER}}"
    - name: home
        path: /lib/systemd/system/nodered.service
        regexp: 'WorkingDirectory='
        line: "WorkingDirectory={{ansible_env.HOME}}"
- name: Reload systemd
  become: yes
    daemon_reload: yes
1 Like

There is also a slightly more feature-rich version of a service file in my alt-installer.

Which may also give you some ideas about not having to do a global install from Ansible.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.