Start a service at startup with Ansible

Solution 1:

Your question is very vague and does not provide much information. However, regarding

... I can't find a proper Ansible module to define services ...

you may have a look into the documentation of the systemd_module.

To

... ensure that they run on startup ...

you could use something like

- name: Make sure {{ SERVICE }} is started and enabled
  systemd:
    name: "{{ SERVICE }}"
    state: started
    enabled: enabled

To be able to start and enable a "service" via the systemd_module you'll need just a systemd service file.

Further Documentation

  • Manage services
  • Writing basic systemd service files

One example for creating and managing a simple service is

  • Installing and running Prometheus node_exporter as a service via Ansible