{"id":19472131,"url":"https://github.com/psykulsk/ansibleconnect","last_synced_at":"2025-04-25T12:31:21.844Z","repository":{"id":57410560,"uuid":"218884573","full_name":"psykulsk/ansibleconnect","owner":"psykulsk","description":"Connect to all hosts from the inventory with one command","archived":false,"fork":false,"pushed_at":"2020-10-06T20:22:46.000Z","size":1278,"stargazers_count":26,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-23T09:17:06.085Z","etag":null,"topics":["ansible","developer-tools","devops","devops-tools","inventory","ssh","ssh-agent","ssh-keys","sshpass","tmux","tmux-shells"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/psykulsk.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-01T00:37:24.000Z","updated_at":"2024-07-03T13:30:47.000Z","dependencies_parsed_at":"2022-08-27T22:02:23.726Z","dependency_job_id":null,"html_url":"https://github.com/psykulsk/ansibleconnect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psykulsk%2Fansibleconnect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psykulsk%2Fansibleconnect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psykulsk%2Fansibleconnect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psykulsk%2Fansibleconnect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psykulsk","download_url":"https://codeload.github.com/psykulsk/ansibleconnect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250817622,"owners_count":21492187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","developer-tools","devops","devops-tools","inventory","ssh","ssh-agent","ssh-keys","sshpass","tmux","tmux-shells"],"created_at":"2024-11-10T19:13:00.460Z","updated_at":"2025-04-25T12:31:21.820Z","avatar_url":"https://github.com/psykulsk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansibleconnect - connect to all hosts from the inventory with one command\n\n\nAnsible Version | CI Status\n---------|:---------\n2.7    | [![Ansible 2.7 Build Status](https://travis-ci.com/psykulsk/ansibleconnect.svg?branch=master\u0026\u0026env=USED_ANSIBLE_VERSION=2.7)](https://travis-ci.com/psykulsk/ansibleconnect)\n2.8    | [![Ansible 2.8 Build Status](https://travis-ci.com/psykulsk/ansibleconnect.svg?branch=master\u0026\u0026env=USED_ANSIBLE_VERSION=2.8)](https://travis-ci.com/psykulsk/ansibleconnect)\n2.9    | [![Ansible 2.9 Build Status](https://travis-ci.com/psykulsk/ansibleconnect.svg?branch=master\u0026\u0026env=USED_ANSIBLE_VERSION=2.9)](https://travis-ci.com/psykulsk/ansibleconnect)\n2.10    | [![Ansible 2.10 Build Status](https://travis-ci.com/psykulsk/ansibleconnect.svg?branch=master\u0026\u0026env=USED_ANSIBLE_VERSION=2.10)](https://travis-ci.com/psykulsk/ansibleconnect)\n\n\n## SSH into all hosts in your inventory with one command.\n\nAnsibleconnect creates a bash script based on your ansible inventory.\nThat script will create a new tmux window or session and create a separate pane\nfor each one of your 'sshable' inventory hosts. Inside of each of the\npanes an ssh connection to the pane's host will be established.\n\n![](doc/demo.gif)\n\n### Setup example (on Ubuntu):\n```\nsudo apt install tmux\nsudo apt install sshpass\npip install ansibleconnect\n```\n\n### Usage examples:\n\nConnect to all hosts in inventory:\n```\nsource \u003c(ansibleconnect -i inventory.yml)\n```\n\nConnect to all hosts from group1 and group2:\n```\nsource \u003c(ansibleconnect -i inventory.yml -g 'group1:group2')\n```\n\nConnect to all hosts from group1 except for hosts that are also in group2:\n```\nsource \u003c(ansibleconnect -i inventory.yml -g 'group1:!group2')\n```\n\nConnect to all hosts from inventory except for hosts in group1:\n```\nsource \u003c(ansibleconnect -i inventory.yml -g '!group1')\n```\n\nConnect to all hosts that have AWS provider:\n```\nsource \u003c(ansibleconnect -i inventory.yml -vars provider:aws)\u003e\n```\n\n**NOTE:** In case you don't use bash. You can also use *eval* command, for example:\n```\neval \"$(ansibleconnect -i inventories/inventory.yml)\"\n```\n\n#### Possible flags\n\n* `-i`, `--inventory` - Path to ansible inventory\n* `-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). Example: `-g computes:!storage`\n* `--hosts` - List of hostnames to connect to. Example: `--hosts hostA,hostB`\n* `-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. Example: `-v type:dev,team:ui`\n* `-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.Example: `-novars type:prod,team:sales`\n* `-w`, `--windows` - If present, then the output tmux command will create new window for each host session instead of a new pane\n\n#### Configuration\n\nAnsibleconnect looks for the `ansible.cfg` file in the same locations as ansible. \n\n### Authentication\n\n\n#### ssh-agent\n\nFor authentication one can use ssh keys. `ansibleconnect` will scan the inventory file for connection options (`ansible_ssh_common_args`, `ansible_ssh_user`, `ansible_host`, `ansible_private_key_file`, etc.). 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.\n\n##### ssh-agent setup example\n```\neval $(ssh-agent)\nssh-add ~/.ssh/my_private_key.pem\n```\n\n#### sshpass\n\nIf `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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsykulsk%2Fansibleconnect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsykulsk%2Fansibleconnect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsykulsk%2Fansibleconnect/lists"}