Giter VIP home page Giter VIP logo

oakleaf's Introduction

Oakleaf

使用 Python Fabric 库编写的简易自动化运维工具,类似 Ansible

GitHub release (latest by date) GitHub last commit Travis (.org) Scrutinizer code quality (GitHub/Bitbucket) CodeFactor Grade

oakleaf 目前支持命令

  • get
    • hosts
    • groups
  • run
    • ping
    • command
    • script
    • sysinfo
    • loadinfo
    • download

使用手册

配置hosts文件

[test]
[email protected]=0okm(IJN8uhb

基础使用

$ python oakleaf.py
usage: oakleaf [-h]  ...

Oakleaf Is An Ops Tool , Writen In Python.

optional arguments:
  -h, --help  show this help message and exit

Oakleaf Sub Command:

    get       Get Infomation
    run       Execute Scripts and Commands on target servers

get

$ python oakleaf.py get
usage: get [-h]  ...

positional arguments:

    hosts (ho)  Get Hosts Info
    groups (gro)
                Get Groups Info
  • hosts
    $ python oakleaf.py get hosts
    GROUP   HOSTIP          SSHPORT USER            PASSWORD
    test    192.168.10.139  22      root            0okm(IJN8uhb
    local   192.168.60.17   22      root            redhat
    
  • groups
    $ python oakleaf.py get groups
    GROUP           HOSTS
    test            1
    local           1
    

run

$ python oakleaf.py run
usage: oakleaf run [-h]  ...

positional arguments:

    ping      Ping hosts
    command   Run Command on Hosts
    script    Run Script on Hosts
    copy      Copy Files to Hosts
    file      Set File's Properties on Hosts
    sysinfo   Get System Info from Hosts
    loadinfo  Get System Load Info from Hosts
    chpass    Change Password of Hosts
    download  Download Files on Remote Host
  • ping
    $ python oakleaf.py run ping -A
    [192.168.10.139 >> uname -s]
    [+] 192.168.10.139 Success 493ms
    [192.168.60.17 >> uname -s]
    [-] 192.168.60.17 UnReachable 2000ms
    Reason: timed out
    
  • command
    $ python oakleaf.py run command -g test echo hello world
    [192.168.10.139 >> echo hello world]
    [+] 192.168.10.139 Success 528ms
    Stdout: hello world
    
  • script
    $ python oakleaf.py run script -f scripts\sysinfo -g test
    [192.168.10.139 >> scripts\sysinfo]
    [+] 192.168.10.139 Success 666ms remote: /tmp/sysinfo
    [192.168.10.139 >> chown -R root:root /tmp/sysinfo]
    [+] 192.168.10.139 Success 707ms
    [192.168.10.139 >> chmod -R 754 /tmp/sysinfo]
    [+] 192.168.10.139 Success 886ms
    [192.168.10.139 >> /bin/sh /tmp/sysinfo ]
    [+] 192.168.10.139 Success 599ms
    Stdout: 
    CPU Info >>>
        Model:        Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz
        Frequency:    2000.000MHz
        Cache:        15360 KB
        Process Count: 6
    ......
    
  • copy
    $ python oakleaf.py run copy -f scripts\sysinfo -g test -d /tmp/ -o root -p 777
    [192.168.10.139 >> scripts\sysinfo]
    [+] 192.168.10.139 Success 657ms remote: /tmp/sysinfo
    [192.168.10.139 >> chown -R root:root /tmp/sysinfo]
    [+] 192.168.10.139 Success 526ms
    [192.168.10.139 >> chmod -R 777 /tmp/sysinfo]
    [+] 192.168.10.139 Success 517ms
    
  • file
    $ python oakleaf.py run file -f /tmp/sysinfo -g test -o root -p 777
    [192.168.10.139 >> chown -R root:root /tmp/sysinfo]
    [+] 192.168.10.139 Success 680ms
    [192.168.10.139 >> chmod 777 /tmp/sysinfo]
    [+] 192.168.10.139 Success 553ms
    
  • sysinfo
    $ python oakleaf.py run sysinfo -g test
    [192.168.10.139 >> yum install -y curl]
    [+] 192.168.10.139 Success 131ms
    [192.168.10.139 >> curl -O -k -L https://raw.githubusercontent.com/serchaofan/laogu-scripts/master/scripts/shell/info/sysinfo.sh]
    
    [+] 192.168.10.139 Success 168ms
    [192.168.10.139 >> chmod +x ~/sysinfo.sh]
    [+] 192.168.10.139 Success 509ms
    [192.168.10.139 >> sh ~/sysinfo.sh]
    [+] 192.168.10.139 Success 572ms
    Stdout:
    CPU Info >>>
        Model:        Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz
        Frequency:    2000.000MHz
        Cache:        15360 KB
        Process Count: 6
    .......
    
  • loadinfo
    $ python oakleaf.py run loadinfo -g test
    [192.168.10.139 >> yum install -y curl]
    [+] 192.168.10.139 Success 134ms
    [192.168.10.139 >> curl -O -k -L https://raw.githubusercontent.com/serchaofan/laogu-scripts/master/scripts/shell/info/loadinfo.sh]
    [+] 192.168.10.139 Success 129ms
    [192.168.10.139 >> chmod +x ~/loadinfo.sh]
    [+] 192.168.10.139 Success 515ms
    [192.168.10.139 >> sh ~/loadinfo.sh]
    [+] 192.168.10.139 Success 643ms
    Stdout: =======================================================
    Kernel Version: 3.10.0-957.el7.x86_64
    HostName:       ci-test
    =======================================================
    Interface       IP Address
    ens192          192.168.10.139/24
    docker0         172.17.0.1/16
    br-cb3029830afb         172.18.0.1/16
    ......
    
  • download
    $ python oakleaf.py run download -g test --url https://raw.githubusercontent.com/serchaofan/laogu-scripts/master/scripts/shell/info/loadinfo.sh
    [192.168.10.139 >> yum install -y curl]
    [+] 192.168.10.139 Success 376ms
    [192.168.10.139 >> curl -O -k -L https://raw.githubusercontent.com/serchaofan/laogu-scripts/master/scripts/shell/info/loadinfo.sh]
    [+] 192.168.10.139 Success 787ms
    

oakleaf's People

Contributors

serchaofan avatar

Watchers

James Cloos avatar  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.