All Projects → selivan → ansible-ssh

selivan / ansible-ssh

Licence: other
Script to connect to managed hosts using Ansible inventory and config.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to ansible-ssh

ansible-yaml inventory
Ansible dynamic inventory reading the inventory from YAML file.
Stars: ✭ 19 (-62.75%)
Mutual labels:  ansible-inventory
ansible-dns-inventory
A dynamic inventory script for Ansible that uses DNS TXT records
Stars: ✭ 20 (-60.78%)
Mutual labels:  ansible-inventory
yaani
Yet another Ansible Netbox inventory
Stars: ✭ 12 (-76.47%)
Mutual labels:  ansible-inventory
simple-ansible-inventory
A simple, clean and easily readable Ansible inventory
Stars: ✭ 25 (-50.98%)
Mutual labels:  ansible-inventory
itop-utilities
Utilities scripts for itop, an open source cmdb. Empowers CMDB by connecting it to other system like Ansible.
Stars: ✭ 38 (-25.49%)
Mutual labels:  ansible-inventory
ansible-pull-example
example skeleton repo for setting up ansible-pull infrastructure
Stars: ✭ 22 (-56.86%)
Mutual labels:  ansible-inventory
Ansible-inventory-file-examples
Examples and counter-examples of Ansible inventory files
Stars: ✭ 25 (-50.98%)
Mutual labels:  ansible-inventory
ansible-nutanix-inventory
A dynamic inventory script for Ansible that interacts with the Nutanix API
Stars: ✭ 23 (-54.9%)
Mutual labels:  ansible-inventory

ansible-ssh

An Ansible installation has all necessary parameters for connecting to managed hosts. Duplicating these parameters in ~/.ssh/config is not convenient, especially if a dynamic inventory is used.

This script parses ansible configuration to get these parameters. Just place it somewhere in your $PATH, like ~/.local/bin.

Considered inventory variables: ansible_host, ansible_ssh_host, ansible_user, ansible_ssh_user, ansible_port, ansible_ssh_port, ansible_ssh_private_key_file, ansible_ssh_common_args, ansible_ssh_extra_args.

Considered configuration variables: ssh_args, ssh_executable.

Jinja templates inside variables are rendered, like ansible_ssh_common_args="{{ my_ssh_args }}".

How it works:

user@work$ cd my_ansible_repo
user@work$ cat hosts | grep server1
server1 ansible_host=192.168.0.1 ansible_user=root ansible_port=2222
user@work$ cat ansible.cfg | grep ssh_args
ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s

user@work$ ansible-ssh server1
ssh_args:  -C -o ControlMaster=auto -o ControlPersist=60s
ansible_host: 192.168.0.1
ansible_user: root
ansible_port: 2222
ansible_ssh_common_args:
result command: ssh [email protected] -C -o ControlMaster=auto -o ControlPersist=60s -p 2222

root@server1#

Options:

  • [-i INVENTORY] specify inventory file for ansible

  • all options and arguments after the hostname are passed to ssh.

Requirements

  • Ansible
  • jq

Build

Not necessary for end users, just some tooling to use jinja template.

./build.sh

P.S. If you like it, don't forget to put a star on its github repo.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].