8000 GitHub - abondis/ansible-cli-helper: CLI to manage multiple environments with Ansible, and reuse host definitions to SSH and run commands
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

CLI to manage multiple environments with Ansible, and reuse host definitions to SSH and run commands

License

Notifications You must be signed in to change notification settings

abondis/ansible-cli-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible CLI Helper

Table of Contents

Description

This script creates an interactive shell to run common commands on servers using ansible.

Dependencies

  • ansible
  • ssh

Installation

Clone the repository somewhere and add main.py into your path (ie: ln -s $(PWD)/make.py ~/.local/bin/ansible_helper)

  • [ ] TODO: rename modules
  • [ ] TODO: have a proper setup.py

Configuration

Copy config_sample.py to config.py in your ansible project.

You also need to configure your ansible hosts and their specific SSH options.

Using a jumphost

If for example some hosts are not available publicly and you need to go through a jumphost to connect to it, configure your `hosts.yml` accordingly.

For example:

all:
  hosts:
    public:
      ansible_host: 192.168.10.10
    private:
      ansible_ssh_extra_args: -o "ProxyJump=192.168.10.10"

Usage

Start the CLI using python make.py. Commands have a basic autocomplete and shows suggestions.

Here is a summary of the available commands:

  • help: show possible commands
  • switch environment: env nameofenv . NOTE: env is just a filter for ansible hosts. For example for srv1:web:prod you could use any part or all of it to match an environment.
  • list hosts configured for the current environment: hosts
  • list hosts impacted by an action: list someactionname
  • check potential impact of an action check someactionname
  • run an action run someactionname
  • ssh into a host: ssh nameofhost
  • show logs: logs someservicename. someservicename is defined in the configuration and will remotely call whatever command you want to run (ie: journalctl -f)

Pass limits or arguments to commands

it is possible to narrow down hosts selected when running an action/check, by adding the following to the command:

  • -o: this will pass whatever is passed to -o to ansible. For exemple this will print the help
    list main -o="--help"
        

    And this will limit the listing to hosts matching myhost

    list main -l myhost
        

For now only list check and run support those options

Troubleshooting

About

CLI to manage multiple environments with Ansible, and reuse host definitions to SSH and run commands

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0