core.wait_for_target#

Wait for a target to be up or down#

Blocks until the step’s target becomes reachable, e.g. after a reboot, or unreachable, e.g. during shutdown. The target is the step’s ‘target’, by default the config’s ‘cijoe.default_target’, and must be one reached over SSH, ‘[cijoe.targets.<name>.ssh]’.

Example Use Case#

A typical task might look like:

- name: reboot
  target: guest
  run: shutdown -r now

- name: wait_for_down
  target: guest
  uses: core.wait_for_target
  with:
    state: "down"
    timeout: 60

- name: wait_for_up
  target: guest
  uses: core.wait_for_target
  with:
    state: "up"
    timeout: 300

State Detection#

The target is considered up when its SSH port accepts a connection and a simple command succeeds over it. To ensure portability across Linux, macOS, BSD, and Windows, the hostname command is used as the probe. It is down when the port is closed, or open while the command fails.

Retargetable#

True

cijoe.core.scripts.wait_for_target.main(args, cijoe)#

Wait until the target reaches the requested state. Return 0 on success, 1 on timeout or invalid target.

CLI arguments#

  • --state {down,up}

    Desired target state to wait for: ‘down’ or ‘up’. Default: up. (default: up)

  • --timeout TIMEOUT

    Maximum seconds to wait for the desired state. (default: 60)