Git Product home page Git Product logo

aistool's Introduction

Ansible inventory file to ssh config

This is a python tool for updating ssh config from ansible inventory file.

Install

$ pip3 install --user AISTool

From github:

$ pip3 install --user git+https://github.com/hitchhooker/AISTool

Local install

$ git clone https://github.com/hitchhooker/AISTool.git
$ pip3 install .

Usage

$ AISTool -h
usage: AISTool [-h] [-o OUTPUT] [-d] [--with-backup] inventory_file

positional arguments:
  inventory_file        ansible inventory file

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        ssh config output path (default: ~/.ssh/config)
  -d, --dry-run         show new configurations without updating file
  --without-backup      update without backup

# Update ~/.ssh/config from specified inventory file
$ AISTool $INVENTORY_FILE

# Update without backup
$ AISTool $INVENTORY_FILE --without-backup

# Output as a new file
$ AISTool $INVENTORY_FILE -o new_ssh_config

# Show content without output
$ AISTool $INVENTORY_FILE -d

Example

# Input (Inventory File)
$ cat hosts

[group_1]
node1 ansible_ssh_host=192.168.0.5
node2 ansible_ssh_host=192.168.0.6

[group_2]
node3 ansible_host=192.168.0.7
node4 ansible_host=192.168.0.8

# Commnad
$ AISTool hosts -o newconfig
Inventory: hosts
Target: newconfig
No such file, generate a new file: new_ssh_config ...

# Output (SSH Config Format)
$ cat new_ssh_config

Host node1
  HostName 192.168.0.5


Host node2
  HostName 192.168.0.6


Host node3
  HostName 192.168.0.7


Host node4
  HostName 192.168.0.8

aistool's People

Contributors

hitchhooker avatar rasjani avatar yioda 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.