code: def service(
      state, host,
      *args, **kwargs
  ):
      '''
      Manage the state of services. This command checks for the presence of all the
      init systems pyinfra can handle and executes the relevant operation. See init
      system sepcific operation for arguments.
      '''
  
      if host.fact.which('systemctl'):
          yield systemd(state, host, *args, **kwargs)
          return
  
      if host.fact.which('initctl'):
          yield upstart(state, host, *args, **kwargs)
          return
  
      if host.fact.directory('/etc/init.d'):
          yield d(state, host, *args, **kwargs)
          return
  
      if host.fact.directory('/etc/rc.d'):
          yield rc(state, host, *args, **kwargs)
          return
  
      raise OperationError((
          'No init system found '
          '(no systemctl, initctl, /etc/init.d or /etc/rc.d found)'
      )f service(
      state, host,
      *args, **kwargs
  ):
      '''
      Manage the state of services. This command checks for the presence of all the
      init systems pyinfra can handle and executes the relevant operation. See init
      system sepcific operation for arguments.
      '''
  
      if host.fact.which('systemctl'):
          yield systemd(state, host, *args, **kwargs)
          return
  
      if host.fact.which('initctl'):
          yield upstart(state, host, *args, **kwargs)
          return
  
      if host.fact.directory('/etc/init.d'):
          yield d(state, host, *args, **kwargs)
          return
  
      if host.fact.directory('/etc/rc.d'):
          yield rc(state, host, *args, **kwargs)
          return
  
      raise OperationError((
          'No init system found '
          '(no systemctl, initctl, /etc/init.d or /etc/rc.d found)'
      ))
docs: Manage the state of services. This command checks for the presence of all the
      init systems pyinfra can handle and executes the relevant operation. See init
      system sepcific operation for arguments.