keycloak-add-user

Description

Adds a keycloak (admin) user to a Keycloak instance.

Variables

Name Type Default Description

password

string --

The users password. Required

username

string --

The username. Required

keycloak_home

string /opt/keycloak

The path to the keycloak app.

realm

string master

The realm.

Code

doc:
  short_help: Adds a keycloak (admin) user.
  help: |
    Adds a keycloak (admin) user to a Keycloak instance.

args:
  username:
    doc:
      short_help: The username.
    type: string
    empty: false
    required: true
  password:
    doc:
      short_help: The users password.
    type: string
    secret: true
    empty: false
    required: true
    cli:
      enabled: false
  ignore_error:
    doc:
      short_help: Ignore errors (when the user already exists, this fails).
    type: boolean
    required: false
    default: false
  keycloak_home:
    doc:
      short_help: The path to the keycloak app.
    type: string
    required: false
    empty: false
    default: /opt/keycloak
  realm:
    doc:
      short_help: The realm.
    type: string
    required: false
    default: master

frecklets:
- execute-command:
    frecklet::desc:
      short: 'adding keycloak user: {{:: username ::}}'
    command: "{{:: keycloak_home ::}}/bin/add-user-keycloak.sh -r {{:: realm ::}}\
      \ -u {{:: username ::}} -p '{{:: password ::}}'"
    become_user: keycloak
    ignore_error: true
    no_log: true
- init-service-restarted:
    name: keycloak
frecklecute --community keycloak-add-user --help

Usage: frecklecute keycloak-add-user [OPTIONS]

  Adds a keycloak (admin) user to a Keycloak instance.

Options:
  --username USERNAME            The username.  [required]
  --keycloak-home KEYCLOAK_HOME  The path to the keycloak app.
  --realm REALM                  The realm.
  --help                         Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.keycloak_add_user.KeycloakAddUser
#


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

@dataclass
class KeycloakAddUser(AutoPycklet):
    """Adds a keycloak (admin) user to a Keycloak instance.

       Args:
         keycloak_home: The path to the keycloak app.
         password: The users password.
         realm: The realm.
         username: The username.

    """

    FRECKLET_ID = "keycloak-add-user"

    keycloak_home: str = None
    password: str = None
    realm: str = None
    username: str = None


    def __post_init__(self):
        super(KeycloakAddUser, self).__init__(var_names=["keycloak_home", "password", "realm", "username"])


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


#
# module path: pycklets.keycloak_add_user.KeycloakAddUser
#


from pyckles import AutoPycklet

class KeycloakAddUser(AutoPycklet):
    """Adds a keycloak (admin) user to a Keycloak instance.

       Args:
         keycloak_home: The path to the keycloak app.
         password: The users password.
         realm: The realm.
         username: The username.

    """

    FRECKLET_ID = "keycloak-add-user"

    def __init__(self, keycloak_home="/opt/keycloak", password=None, realm="master", username=None):

        super(KeycloakAddUser, self).__init__(var_names=["keycloak_home", "password", "realm", "username"])
        self._keycloak_home = keycloak_home
        self._password = password
        self._realm = realm
        self._username = username

    @property
    def keycloak_home(self):
        return self._keycloak_home

    @keycloak_home.setter
    def keycloak_home(self, keycloak_home):
        self._keycloak_home = keycloak_home

    @property
    def password(self):
        return self._password

    @password.setter
    def password(self, password):
        self._password = password

    @property
    def realm(self):
        return self._realm

    @realm.setter
    def realm(self, realm):
        self._realm = realm

    @property
    def username(self):
        return self._username

    @username.setter
    def username(self, username):
        self._username = username



frecklet_class = KeycloakAddUser