We need a few tasks to add a new systemd service. Code deploys will happen later once the server is configured by Ansible. This will cause our service to fail on startup until the first deploy is done. This chicken and egg situation is addressed with some conditionals in the Ansible playbook.
NOTE: We run our application as root in the service file. We shouldn’t do this but did anyway to keep moving forward. Using root fixed file permission errors caused during startup of our single-file app. This is a known issue in .NET Core 3.1 which will be addressed in a service release.
The application is now properly hosted on our Linux server. NGINX will front requests from the public internet and systemd will ensure our application stays running.
Next we’ll install Redis using a pre-built role from Ansible Galaxy. Also, our Ansible playbook needs some cleanup to keep things maintainable.