How do `service` and `systemd` modules differ?
IntermediateConceptAd-hoc Commands, Modules and Idempotency
Answer
service is a generic wrapper that picks systemd, SysV or others. systemd_service (alias systemd) is specific to systemd and adds daemon_reload, masked, scope: user and enabled control.
- ansible.builtin.systemd_service:
name: myapp
state: restarted
enabled: true
daemon_reload: true
Run daemon_reload after dropping a new unit file, or systemd will keep using the old definition. In containers without systemd the modules fail, which is a common surprise in Molecule tests.
More on Ad-hoc Commands, Modules and Idempotency
What is an ad-hoc command and what is its syntax?BeginnerWhat does `ansible all -m ping` actually test?BeginnerGive practical use cases for ad-hoc commands.IntermediateWhat is the difference between the `command` and `shell` modules?BeginnerCompare `raw`, `command`, `shell` and `script`.IntermediateWhy prefer a dedicated module over `shell`/`command`?Beginner