semvec/pypi-packages huggingface dataset:
search-ansible-hosts 0.0.2
Ansible inventory searching for rapid use
License: MIT
Requires Python: >=3.5.0

# SearchAnsibleHosts

I like using my Ansible inventory when SSH-ing or running a script against a list of devices, but the native method of listing hosts in Ansible (i.e. `ansible --list-hosts some:pattern`) is too slow for me (\~800ms), so I made this to drop that way down (\~50ms).

# Installation

```shell
pip3 install search-ansible-hosts
```

# Usage

```shell
search-ansible-hosts some:pattern
```

Checkout `search-ansible-hosts -h` for the list of options.

I **highly** recommend that you create an alias for this script. For instance, I've got `alias shost=search-ansible-hosts` in my `.bash_profile`.

# Internals

Whenever you run this script, it will create a server that runs in the background if one doesn't exist. The job of that server is to cache the Ansible inventory in memory and listen on a local port. Afterwards, it will act as a client and will send the pattern to the server. The server will send back the list of hosts and then closes the connection to that client, but it will remain in the background, ready to accept any other requests.

The process of importing the required Ansible modules and instantiating the inventory takes the most time, but since the server continues to run in the background, you will only suffer from the delay on the first run of this script (i.e. when there isn't a server).

Technically, the script is only needed to launch the server, after which you can use any program to send the pattern to it. For instance, you can do something like `echo some:pattern | nc 127.0.0.1 16001` so long as the server is already running.
cterm 0.0.9
Fork your input to multiple Terminal windows
License: MIT
Requires Python: >=3.6.0

ClusterTerminal (`cterm`) forwards all keystrokes from a master window to multiple slave windows. Use `cterm` as a method for performing ad hoc tasks, not as a substitute for automation frameworks.

> This is mostly just something I wanted to do out of fun; plenty of similar solutions out there, `tmux` being a very popular one.

![alt text](https://github.com/hSaria/ClusterTerminal/raw/master/.github/ssh_example.gif "Example output")

# Installation

    pip3 install cterm

ClusterTerminal uses the built-in Terminal application of macOS.

# Usage

The most common use case is controlling multiple SSH sessions simultaneously:

    cterm ssh host1 host2

In addition to the master window, the above will create two slaves windows, like so:

    ssh host1
    ssh host2

## Command Arguments

If you want to pass arguments to the command, include it as part of the command. Beware of character escaping where necessary. For example:

    cterm "ssh -l \"some user\"" host1 host2

which will expand to:

    ssh -l "some user" host1
    ssh -l "some user" host2

> You could've also used `cterm "ssh -l 'some user'" host1 host2` to get the same outcome; I only escaped quotes to demo purposes.

## Item Arguments

Similar to a command, you can pass per-item arguments (again, beware of character escaping):

    cterm ssh "\-p 1022 host1" "\-p 2022 host2"

which will expand to:

    ssh -p 1022 host1
    ssh -p 2022 host2

# Tips

You might want to set up an alias for cluster ssh in your `~/.bash_profile`. For instance, `alias cssh="cterm ssh"`, and then call it using `cssh host1 host2`.

In an alias, you can save your normal settings, like `alias cssh="cterm --screen 2 ssh"` to change the default screen.

If you specify the same argument twice, the last instance is the one used. This is useful since you may want to overwrite part of your alias, but not all of it. For example, the following will use screen 1:

    cterm ssh host1 host2 --screen 2 --screen 1

# Limitations

The window must be completely opaque as the scripting capabilities of Terminal ignore the alpha component.