Search code examples
ansiblesystemd

Ansible - Edit a systemd service file


The systemd module: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_module.html

I'm looking for a way to add a Condition to the service file.

For instance:

ConditionPathIsMountPoint=/mnt/myreplication/path/

This would be useful for docker installations, ensuring docker doesn't start containers before a mount they need is actually available.

Sadly, it looks like Ansible doesn't support adding this right now. Am I correct there? Will I need to manually add it, or with lineinfile? Or is there an other way?

EDIT: This question appears to be getting views, so I'll add this:

https://askubuntu.com/questions/659267/how-do-i-override-or-configure-systemd-services

And this answer to another question of mine: https://askubuntu.com/a/1348117/1612

To quote it:

Don't edit files in /lib/systemd/ or /usr/share/systemd as they will get overwritten on updates.


Solution

  • EDIT: This question appears to be getting views, so I'll add this:

    https://askubuntu.com/questions/659267/how-do-i-override-or-configure-systemd-services

    And this answer to another question of mine: https://askubuntu.com/a/1348117/1612

    To quote it:

    Don't edit files in /lib/systemd/ or /usr/share/systemd as they will get overwritten on updates.