We use cookies for personalised adverts on this site. PayPal donation is another mechanism for support if you prefer.

hosted services

  • why unix
  • wet shaving
  • unix beards
  • about this site
  • books
  • RBL service
  • forum
This site needs your support
amountGBP

News

Ads help server costs, we rely on their revenue (and donations, too) to fund hosting.

ansible

  • outline
  • ssh
    • timeouts
    • tunnelling
  • arbitrary scripts

outline

Ansible solve several problems. One of the problems is solves very well is centralising management of systems.

ssh

In most setups you'll be using ansible with ssh as transport for data and commands. In some cases normal problems prevent commands running on the remote machine from finishing in a timely manner or finishing at all. Normal ssh timeouts will not help you here.

timeouts

Linux and unix systems are great at process wrapping. The vast majority of systems will let you specify which binaries to execute, and when then don't you can customise your PATH.

Ansible allows you to specify the ssh_command, however, I found it easiest to wrap my own:

#!/bin/sh

/bin/timeout 300 /bin/ssh "$@"

Was all that was needed.

This method is very effective at stopping long running commands, heavy work loads and remote filesystem blocks will not stop the controlling job.

tunnelling

In some cases you may need to funnel the connection through a 'jump' box (I don't like this term).

Host * !192.168.45.9
  ProxyCommand ssh -W  %h:%p -l ansible@192.168.45.9

In the above example we exclude 192.168.45.9 from the proxy rule so that we can send the traffic via this host.

arbitrary scripts

If Ansible does not happen to have a module for your exact case, you can write your own inline scripts as follows:

- name: http port open
  shell: |
    ss -tln | egrep ':(80|443)\s'
  args:
    executable: /bin/bash

Last modified: 1541287596.27