3

How do you tell systemd that a requirement is satisfied with one of any instance from a list of instances?

Say that I have a target called main_target.target and a service template called serv@.service. During normal operation, the only instances of serv@.service that exist are:

  • serv@ex1
  • serv@ex2
  • serv@ex3

Only one of those instances exist at any given time, and I want to tell main_target.target that it's satisfied whenever any of the three instances exist.

Intuitively, I'd like something similar to SMF's require_any tag, but I haven't been able to find anything like that in any of the systemd documentation.

Note 1: I know that I can make serv@ex1, serv@ex2, serv@ex3 and mutually exclusive with the Conflicts= directive.

Note 2: I also know that I can use the Before= and After= directives to tier the three instances to start in a certain order.

  • What do you mean by "satisfy a target"? Normal targets are just a way to group together units, when the target is run it doesn't really care if a service succeeds or not, that's the service's responsibility. – Centimane Apr 5 '17 at 20:46
0

As you mention you can make the services mutually exclusive with the Conflicts= directive. The systemd targets are only a method for grouping together units, they do not have complex dependency options.

systemd.target

A unit configuration file whose name ends in ".target" encodes information about a target unit of systemd, which is used for grouping units and as well-known synchronization points during start-up.

This unit type has no specific options. See systemd.unit(5) for the common options of all unit configuration files. The common configuration items are configured in the generic [Unit] and [Install] sections. A separate [Target] section does not exist, since no target-specific options may be configured.

systemd.unit for reference.

You can only use directives included in systemd.unit, and it does not include a method for starting only one of multiple services.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.