user-is-member-of-group

Example:

# Add user 'freckles' to group 'wheel'.
- user-is-member-of-group:
    user: freckles
    group: wheel

Description

Ensures a user is member of a group.

Variables

Name Type Default Description

group

string --

The name of the group. Required

user

string --

The name of the user. Required

Examples

Example 1

Add user 'freckles' to group 'wheel'.

Code
- user-is-member-of-group:
    user: freckles
    group: wheel

Code

doc:
  short_help: Ensures a user is member of a group.
  examples:
  - title: Add user 'freckles' to group 'wheel'.
    vars:
      user: freckles
      group: wheel

args:
  user:
    doc:
      short_help: The name of the user.
    type: string
    required: true
  group:
    doc:
      short_help: The name of the group.
    type: string
    required: true

frecklets:
- user-exists:
    name: '{{:: user ::}}'
- group-exists:
    group: '{{:: group ::}}'
- frecklet:
    name: user
    type: ansible-module
    properties:
      elevated: true
      idempotent: true
      internet: false
    desc:
      short: "Ensure user '{{:: user ::}}' is member of group: {{:: group ::}}"
  task:
    become: true
  vars:
    name: '{{:: user ::}}'
    groups:
    - '{{:: group ::}}'
    append: true
frecklecute user-is-member-of-group --help

Usage: frecklecute user-is-member-of-group [OPTIONS]

  Ensures a user is member of a group.

Options:
  --group GROUP  The name of the group.  [required]
  --user USER    The name of the user.  [required]
  --help         Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.user_is_member_of_group.UserIsMemberOfGroup
#


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

@dataclass
class UserIsMemberOfGroup(AutoPycklet):
    """Ensures a user is member of a group.

       Args:
         group: The name of the group.
         user: The name of the user.

    """

    FRECKLET_ID = "user-is-member-of-group"

    group: str = None
    user: str = None


    def __post_init__(self):
        super(UserIsMemberOfGroup, self).__init__(var_names=["group", "user"])


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


#
# module path: pycklets.user_is_member_of_group.UserIsMemberOfGroup
#


from pyckles import AutoPycklet

class UserIsMemberOfGroup(AutoPycklet):
    """Ensures a user is member of a group.

       Args:
         group: The name of the group.
         user: The name of the user.

    """

    FRECKLET_ID = "user-is-member-of-group"

    def __init__(self, group=None, user=None):

        super(UserIsMemberOfGroup, self).__init__(var_names=["group", "user"])
        self._group = group
        self._user = user

    @property
    def group(self):
        return self._group

    @group.setter
    def group(self, group):
        self._group = group

    @property
    def user(self):
        return self._user

    @user.setter
    def user(self, user):
        self._user = user



frecklet_class = UserIsMemberOfGroup