systemd-services-stopped

Description

This frecklet makes sure a list of sytemd services are stopped.

Non-existing services will be ignored.

Variables

Name Type Default Description

services

list []

A list of services.

Code

doc:
  short_help: A list of init-service to stop (if they exist) using Ansible.
  help: |
    This frecklet makes sure a list of sytemd services are stopped.

    Non-existing services will be ignored.

args:
  services:
    doc:
      short_help: A list of services.
    type: list
    schema:
      type: string
    required: true
    empty: true
    default: []
    cli:
      metavar: SERVICE_NAME
      param_type: argument

meta:
  tags:
  - service
  - systemd
  - init
  - impl

frecklets:
- frecklet:
    type: ansible-module
    name: service_facts
    desc:
      short: gathering facts about init services
- task:
    become: true
    loop: '{{:: services ::}}'
    loop_control:
      loop_var: __service_name__
    when: __service_name__ + '.service' in ansible_facts.services.keys()
  frecklet:
    type: ansible-module
    name: service
    desc:
      short: "stop services: {{:: services | join(' ') ::}}"
  vars:
    name: '{{ __service_name__ }}'
    idempotent: true
    internet: false
    elevated: true
    references:
      "'service' Ansible module'": https://docs.ansible.com/ansible/latest/modules/service_module.html
    state: stopped
frecklecute systemd-services-stopped --help

Usage: frecklecute systemd-services-stopped [OPTIONS] SERVICE_NAME

  This frecklet makes sure a list of sytemd services are stopped.

  Non-existing services will be ignored.

Options:
  --help  Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.systemd_services_stopped.SystemdServicesStopped
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class SystemdServicesStopped(AutoPycklet):
    """This frecklet makes sure a list of sytemd services are stopped.

     Non-existing services will be ignored.

       Args:
         services: A list of services.

    """

    FRECKLET_ID = "systemd-services-stopped"

    services: List = None


    def __post_init__(self):
        super(SystemdServicesStopped, self).__init__(var_names=["services"])


frecklet_class = SystemdServicesStopped
# -*- coding: utf-8 -*-


#
# module path: pycklets.systemd_services_stopped.SystemdServicesStopped
#


from pyckles import AutoPycklet

class SystemdServicesStopped(AutoPycklet):
    """This frecklet makes sure a list of sytemd services are stopped.

     Non-existing services will be ignored.

       Args:
         services: A list of services.

    """

    FRECKLET_ID = "systemd-services-stopped"

    def __init__(self, services=None):

        super(SystemdServicesStopped, self).__init__(var_names=["services"])
        self._services = services

    @property
    def services(self):
        return self._services

    @services.setter
    def services(self, services):
        self._services = services



frecklet_class = SystemdServicesStopped