Need help using doppler from a systemd service (ubuntu)

Hi,

I cant seem to get doppler to run from a systemd service (ubuntu 20.04)

Doppler is configured like this: (executed over ssh as root user)

export HISTIGNORE='doppler*'
echo '${doppler-token}' | doppler configure set token

My systemd service script looks like this:

[Unit]
Description=what core

[Service]
ExecStart=doppler run /root/what/bin/core

[Install]
WantedBy=multi-user.target

Checking the status of the service:

root@test:~# systemctl status what-core
● what-core.service - what core
     Loaded: loaded (/etc/systemd/system/what-core.service; enabled; vendor preset: enabl>
     Active: failed (Result: exit-code) since Thu 2022-08-04 18:11:04 UTC; 11min ago
    Process: 7584 ExecStart=/usr/bin/doppler run /root/what/bin/core (code=exited, status>
   Main PID: 7584 (code=exited, status=1/FAILURE)

Aug 04 18:11:04 test systemd[1]: Started what core.
Aug 04 18:11:04 test doppler[7584]: Unable to determine home directory
Aug 04 18:11:04 test doppler[7584]: Doppler Error: $HOME is not defined
Aug 04 18:11:04 test systemd[1]: what-core.service: Main process exited, code=exited, sta>
Aug 04 18:11:04 test systemd[1]: what-core.service: Failed with result 'exit-code'.

And doppler seems properly configured:

root@test:~# doppler configure
┌───────┬──────────────────┬───────┐
│ NAME  │ VALUE            │ SCOPE │
├───────┼──────────────────┼───────┤
│ token │ dp.st.stg.…9ljA8 │ /root │
└───────┴──────────────────┴───────┘

Please help :slight_smile:
Also im not 100% sure of the HISTIGNORE usage - Im a bit of a linux noob.

Hi @fritzkeyzer!

Welcome to the Doppler Community!

What you’re running into there is the fact that the Doppler CLI requires the HOME environment variable be set. Could you try updating your unitfile to something like this?

[Unit]
Description=what core

[Service]
ExecStart=doppler run /root/what/bin/core
Environment="HOME=/some/path/here"

[Install]
WantedBy=multi-user.target

and then see if you keep getting the same error?

Regards,
-Joel

Hi @watsonian thanks for the response!

I’ve updated my service to this:

[Unit]
Description=what core

[Service]
Environment="HOME=/root"
ExecStart=doppler run /root/what/bin/core

[Install]
WantedBy=multi-user.target

I get this error:

root@test:~# systemctl status what-core
● what-core.service - what core
     Loaded: loaded (/etc/systemd/system/what-core.service; enabled; vendor preset: enabl>
     Active: failed (Result: exit-code) since Thu 2022-08-04 19:26:56 UTC; 1s ago
    Process: 924 ExecStart=/usr/bin/doppler run /root/what/bin/core (code=exited, status=>
   Main PID: 924 (code=exited, status=1/FAILURE)

Aug 04 19:26:56 test systemd[1]: Started what core.
Aug 04 19:26:56 test doppler[924]: Doppler Error: you must provide a token
Aug 04 19:26:56 test systemd[1]: what-core.service: Main process exited, code=exited, sta>
Aug 04 19:26:56 test systemd[1]: what-core.service: Failed with result 'exit-code'.

FYI, running doppler run /root/what/bin/core manually works perfectly fine.

Still a bit stuck…

Solved my problem a different way.
All I need is for the executable to run on startup.

Added this line to the crontab:

@reboot doppler run /.../.../core

Ah, that works! To solve your systemd issue though, I think what you needed was this added to the [service] block as well:

WorkingDirectory=/root

Without that it wasn’t running inside /root which is where the token you were setting up was scoped.