Giter Club home page Giter Club logo

ansible-ssh's Introduction

ansible-ssh

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

This script parses ansible configuration to get that 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.

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

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

ansible-ssh's People

Contributors

obilodeau avatar selivan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.