Skip to main content

Connect to all hosts from the ansible inventory with one command

Project description

Ansibleconnect - connect to all hosts from the inventory with one command

Tested with Python >= 3.5

Ansible Version CI Status
2.5 Ansible 2.5 Build Status
2.6 Ansible 2.6 Build Status
2.7 Ansible 2.7 Build Status
2.8 Ansible 2.8 Build Status
2.9 Ansible 2.9 Build Status

SSH into all hosts in your inventory with one command.

Ansibleconnect creates a bash script based on your ansible inventory. That script will create a new tmux session and create a separate pane for each one of your 'sshable' inventory hosts. Inside of each of the panes an ssh connection to the pane's host will be established.

Setup example (on Ubuntu):

sudo apt install tmux
sudo apt install sshpass
git clone https://github.com/psykulsk/ansibleconnect.git
cd ansibleconnect
python3 -m pip install .

Usage examples:

Connect to all hosts in inventory:

source <(ansibleconnect -i inventory.yml)

Connect to all hosts from group1 and group2:

source <(ansibleconnect -i inventory.yml -g 'group1:group2')

Connect to all hosts from group1 except for hosts that are also in group2:

source <(ansibleconnect -i inventory.yml -g 'group1:!group2')

Connect to all hosts from inventory except for hosts in group1:

source <(ansibleconnect -i inventory.yml -g '!group1')

Connect to all hosts that have AWS provider:

source <(ansibleconnect -i inventory.yml -vars provider:aws)>

Possible flags

  • -i, --inventory - Path to ansible inventory
  • -g, --groups - Inventory groups of hosts to connect to (multiple groups should be concentrated with :. ! in front of group name means that ansibleconnect should not connect to hosts form this group)
  • --hosts - List of hostnames to connect to. Example: --hosts hostA,hostB
  • -vars, --variables - Variables that host should have defined in inventory to connect to it. Accepted format: key:value in case where host should have variable with specific value or key in case where host should have defined variable no matter what value.
  • -novars, --no-variables - Variables that host should not have defined in inventory to connect to it. Accepted format: key:value in case where host should not have variable with specific value or key in case where host should not have defined variable no matter what value.

Authentication

ssh-agent

For authentication one can use ssh keys. ansibleconnect will scan the inventory file for connection options (ansible_ssh_common_args, ansible_ssh_user, ansible_host). Ssh keys can be passed via them. Otherwise, one can use the ssh-agent tool. Environment args (SSH_AGENT_PID and SSH_AUTH_SOCK) will be passed to each one of the tmux shells.

ssh-agent setup example
eval $(ssh-agent)
ssh-add ~/.ssh/my_private_key\

sshpass

If ansible_ssh_pass variable is used in the inventory, one should installl the sshpass and make it discoverable via PATH. Please note that when using the sshpass, password will passed in plaintext and it will be saved in each of the tmux shells' history.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansibleconnect-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansibleconnect-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file ansibleconnect-0.1.0.tar.gz.

File metadata

  • Download URL: ansibleconnect-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.8

File hashes

Hashes for ansibleconnect-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3ad064d3b2a27cb904d22426dc7fec027c9c722605cc978eacefd9bcab73eed7
MD5 c497d18f422766dceb131971058cc758
BLAKE2b-256 0d5fa047dd7f4fae15a50e6b0606877d559729fe7a60e20e8ca7c1a7fde9ff60

See more details on using hashes here.

File details

Details for the file ansibleconnect-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ansibleconnect-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.8

File hashes

Hashes for ansibleconnect-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9b2b8f6881b936701b8df149c15733c5b19de75d9924c0781b358e773e58ee6
MD5 78182cbf52cbfde8fdf521c8db419ef2
BLAKE2b-256 9d3252319446f964c240898ff40ebf400f0d4b95bdbbe850ae646c604d03ca98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page