Connect to all hosts from the ansible inventory with one command
Ansibleconnect - connect to all hosts from the inventory with one command
|Ansible Version||CI 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 window or 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 pip install ansibleconnect
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)>
NOTE: In case you don't use bash. You can also use eval command, for example:
eval "$(ansibleconnect -i inventories/inventory.yml)"
--inventory- Path to ansible inventory
--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:
--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.
--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.
For authentication one can use ssh keys.
ansibleconnect will scan the inventory file for connection options (
ansible_private_key_file, etc.). Ssh keys can be passed via them. Otherwise, one can use the
ssh-agent tool. Environment args (
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.pem
ansible_ssh_pass variable is used in the inventory, one should install 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.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size ansibleconnect-1.0.2-py3-none-any.whl (8.8 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size ansibleconnect-1.0.2.tar.gz (6.8 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for ansibleconnect-1.0.2-py3-none-any.whl