ssh-key-no-password-exists

Description

Ensures a password-less ssh key exists for a user.

Creates one with empty password if necessary.

TODO: suppor an (optional) password

Variables

Name Type Default Description

path

string --

The path to the ssh key. Required

user

string --

The name of the user.

Code

doc:
  short_help: Ensures a password-less ssh key exists for a user.
  help: |
    Ensures a password-less ssh key exists for a user.

    Creates one with empty password if necessary.

    TODO: suppor an (optional) password

args:
  user:
    doc:
      short_help: The name of the user.
    type: string
    required: false
  path:
    doc:
      short_help: The path to the ssh key.
    type: string
    required: true
    cli:
      param_type: argument

frecklets:
- parent-folder-exists:
    path: '{{:: path ::}}'
    owner: '{{:: user ::}}'
- frecklet:
    name: command
    type: ansible-module
    desc:
      short: 'create ssh key (if necessary): {{:: path ::}}'
  task:
    become: '{{:: user | false_if_empty ::}}'
    become_user: '{{:: user ::}}'
  vars:
    free_form: 'ssh-keygen -q -t rsa -f {{:: path ::}} -C "" -N ""'
    creates: '{{:: path ::}}'
frecklecute ssh-key-no-password-exists --help

Usage: frecklecute ssh-key-no-password-exists [OPTIONS] PATH

  Ensures a password-less ssh key exists for a user.

  Creates one with empty password if necessary.

  TODO: suppor an (optional) password

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


#
# module path: pycklets.ssh_key_no_password_exists.SshKeyNoPasswordExists
#


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

@dataclass
class SshKeyNoPasswordExists(AutoPycklet):
    """Ensures a password-less ssh key exists for a user.

     Creates one with empty password if necessary.

     TODO: suppor an (optional) password

       Args:
         path: The path to the ssh key.
         user: The name of the user.

    """

    FRECKLET_ID = "ssh-key-no-password-exists"

    path: str = None
    user: str = None


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


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


#
# module path: pycklets.ssh_key_no_password_exists.SshKeyNoPasswordExists
#


from pyckles import AutoPycklet

class SshKeyNoPasswordExists(AutoPycklet):
    """Ensures a password-less ssh key exists for a user.

     Creates one with empty password if necessary.

     TODO: suppor an (optional) password

       Args:
         path: The path to the ssh key.
         user: The name of the user.

    """

    FRECKLET_ID = "ssh-key-no-password-exists"

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

        super(SshKeyNoPasswordExists, self).__init__(var_names=["path", "user"])
        self._path = path
        self._user = user

    @property
    def path(self):
        return self._path

    @path.setter
    def path(self, path):
        self._path = path

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

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



frecklet_class = SshKeyNoPasswordExists