Import _make_systemctl_cmd from facts.systemd
@@ -5,27 +5,11 @@ Manage systemd services.
from __future__ import unicode_literals
from pyinfra.api import operation
-from pyinfra.facts.systemd import SystemdEnabled, SystemdStatus
+from pyinfra.facts.systemd import _make_systemctl_cmd, SystemdEnabled, SystemdStatus
from .util.service import handle_service_control
-def _make_systemctl_cmd(user_mode=False, machine=None, user_name=None):
- # base command for normal and user mode
- systemctl_cmd = 'systemctl --user' if user_mode else 'systemctl'
-
- # add user and machine flag if given in args
- if machine is not None:
- if user_name is not None:
- machine_opt = '--machine={1}@{0}'.format(machine, user_name)
- else:
- machine_opt = '--machine={0}'.format(machine)
-
- systemctl_cmd = '{0} {1}'.format(systemctl_cmd, machine_opt)
-
- return systemctl_cmd
-
-
@operation
def daemon_reload(
user_mode=False, machine=None, user_name=None, state=None, host=None,
