Return a list of all disabled services root Enable/disable/mask unit files in the specified root directory CLI Example: .. code-block:: bash salt '*' service.get_disabled
(root=None)
| 518 | |
| 519 | |
| 520 | def get_disabled(root=None): |
| 521 | """ |
| 522 | Return a list of all disabled services |
| 523 | |
| 524 | root |
| 525 | Enable/disable/mask unit files in the specified root directory |
| 526 | |
| 527 | CLI Example: |
| 528 | |
| 529 | .. code-block:: bash |
| 530 | |
| 531 | salt '*' service.get_disabled |
| 532 | """ |
| 533 | ret = set() |
| 534 | # Get disabled systemd units. Can't use --state=disabled here because it's |
| 535 | # not present until systemd 216. |
| 536 | out = __salt__["cmd.run"]( |
| 537 | _systemctl_cmd("--full --no-legend --no-pager list-unit-files", root=root), |
| 538 | python_shell=False, |
| 539 | ignore_retcode=True, |
| 540 | ) |
| 541 | for line in salt.utils.itertools.split(out, "\n"): |
| 542 | try: |
| 543 | fullname, unit_state = line.strip().split()[:2] |
| 544 | except ValueError: |
| 545 | continue |
| 546 | else: |
| 547 | # Arch Linux adds a third column, which we want to ignore |
| 548 | if unit_state.split()[0] != "disabled": |
| 549 | continue |
| 550 | try: |
| 551 | unit_name, unit_type = fullname.rsplit(".", 1) |
| 552 | except ValueError: |
| 553 | continue |
| 554 | if unit_type in VALID_UNIT_TYPES: |
| 555 | ret.add(unit_name if unit_type == "service" else fullname) |
| 556 | |
| 557 | # Add in any sysvinit services that are disabled |
| 558 | ret.update({x for x in _get_sysv_services(root) if not _sysv_enabled(x, root)}) |
| 559 | return sorted(ret) |
| 560 | |
| 561 | |
| 562 | def get_static(root=None): |
nothing calls this directly
no test coverage detected