wait-for-ssh

Example:

# Wait for host ssh on host 'example.com' to be available (port 22).
- wait-for-ssh:
    host: example.com

Description

Wait for ssh service to be available on a host.

Variables

Name Type Default Description

host

string --

The name or IP address of the host. Required

delay

integer 0

Number of seconds to wait before starting to poll.

extra_wait_time

integer 0

Wait an extra amount of seconds before continuing.

port

integer 22

The port ssh listens on.

timeout

integer 300

Maximum number of seconds to wait for.

Examples

Example 1

Wait for host ssh on host 'example.com' to be available (port 22).

Code
- wait-for-ssh:
    host: example.com

Code

doc:
  short_help: Wait for ssh service to be available on a host.
  examples:
  - title: Wait for host ssh on host 'example.com' to be available (port 22).
    vars:
      host: example.com
args:
  host:
    doc:
      short_help: The name or IP address of the host.
    type: string
    required: true
  port:
    doc:
      short_help: The port ssh listens on.
    type: integer
    required: false
    default: 22
  delay:
    doc:
      short_help: Number of seconds to wait before starting to poll.
    type: integer
    required: false
    default: 0
  timeout:
    doc:
      short_help: Maximum number of seconds to wait for.
    type: integer
    required: false
    default: 300
  extra_wait_time:
    doc:
      short_help: Wait an extra amount of seconds before continuing.
    type: integer
    required: false
    default: 0
frecklets:
- frecklet:
    name: wait_for
    type: ansible-module
    desc:
      short: "wait for ssh on host '{{:: host ::}}' to become available"
    properties:
      elevated: false
      idempotent: false
      internet: false
  task:
    connection: local
  vars:
    port: '{{:: port ::}}'
    host: '{{:: host ::}}'
    search_regex: OpenSSH
    delay: '{{:: delay ::}}'
    timeout: '{{:: timeout ::}}'
- sleep:
    frecklet::skip: '{{:: extra_wait_time | true_if_equal(0) ::}}'
    time: '{{:: extra_wait_time ::}}'
frecklecute wait-for-ssh --help

Usage: frecklecute wait-for-ssh [OPTIONS]

  Wait for ssh service to be available on a host.

Options:
  --host HOST                     The name or IP address of the host.
                                  [required]
  --delay DELAY                   Number of seconds to wait before starting to
                                  poll.
  --extra-wait-time EXTRA_WAIT_TIME
                                  Wait an extra amount of seconds before
                                  continuing.
  --port PORT                     The port ssh listens on.
  --timeout TIMEOUT               Maximum number of seconds to wait for.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.wait_for_ssh.WaitForSsh
#


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

@dataclass
class WaitForSsh(AutoPycklet):
    """Wait for ssh service to be available on a host.

       Args:
         delay: Number of seconds to wait before starting to poll.
         extra_wait_time: Wait an extra amount of seconds before continuing.
         host: The name or IP address of the host.
         port: The port ssh listens on.
         timeout: Maximum number of seconds to wait for.

    """

    FRECKLET_ID = "wait-for-ssh"

    delay: int = None
    extra_wait_time: int = None
    host: str = None
    port: int = None
    timeout: int = None


    def __post_init__(self):
        super(WaitForSsh, self).__init__(var_names=["delay", "extra_wait_time", "host", "port", "timeout"])


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


#
# module path: pycklets.wait_for_ssh.WaitForSsh
#


from pyckles import AutoPycklet

class WaitForSsh(AutoPycklet):
    """Wait for ssh service to be available on a host.

       Args:
         delay: Number of seconds to wait before starting to poll.
         extra_wait_time: Wait an extra amount of seconds before continuing.
         host: The name or IP address of the host.
         port: The port ssh listens on.
         timeout: Maximum number of seconds to wait for.

    """

    FRECKLET_ID = "wait-for-ssh"

    def __init__(self, delay=None, extra_wait_time=None, host=None, port=22, timeout=300):

        super(WaitForSsh, self).__init__(var_names=["delay", "extra_wait_time", "host", "port", "timeout"])
        self._delay = delay
        self._extra_wait_time = extra_wait_time
        self._host = host
        self._port = port
        self._timeout = timeout

    @property
    def delay(self):
        return self._delay

    @delay.setter
    def delay(self, delay):
        self._delay = delay

    @property
    def extra_wait_time(self):
        return self._extra_wait_time

    @extra_wait_time.setter
    def extra_wait_time(self, extra_wait_time):
        self._extra_wait_time = extra_wait_time

    @property
    def host(self):
        return self._host

    @host.setter
    def host(self, host):
        self._host = host

    @property
    def port(self):
        return self._port

    @port.setter
    def port(self, port):
        self._port = port

    @property
    def timeout(self):
        return self._timeout

    @timeout.setter
    def timeout(self, timeout):
        self._timeout = timeout



frecklet_class = WaitForSsh