zoukankan      html  css  js  c++  java
  • 深入学习saltstack远程执行(四)

    结构:

    命令:salt(固定的)

    目标:‘*’    

    模块:cmd.run   一共有150多种模块

    返回:执行后返回的结构

    详解目标

                        1 minion ID(ID名字)

                        2 通配符  (*,daxian00[1|2|3],daxian00[1-3]等)

                        3  列表     (salt -L 'daxian001,daxian002' test.ping)

                        4 正则表达式(slat -E 'daxian(001|002)*' test.ping)

                        所有匹配目标的方式,都可以用到TOPfile里面指定

      

    详解模块(常用的)

    显示arp表  

     salt '*' network.arp   

    显示主机名          

    salt '*' network.get_hostname
    web01:
    web02
    web02:
    web03

    查看服务是否存活

    salt '*' service.available sshd
    web01:
    True
    web02:
    True

     查看所有正在运行的服务

    salt '*' service.get_all

    重载

    salt '*' service.reload <service name>

    重启

    salt '*' service.restart <service name>

    启动

    salt '*' service.start <service name>

    状态

    salt '*' service.status <service name>

    停止

    salt '*' service.stop <service name>

    拷贝文件

    salt-cp '*' /etc/hosts /tmp/

    查看top都干什么事情

    salt '*' state.show_top

    返回程序:

       将返回的程序返回到mysql 数据库里

       

    编写状态模块:

      放在:/srv/salt/_modules

      命名: 文件名就是模块名 my_disk.py

      

    def list():
      cmd = 'df -h'
      ret = __salt__['cmd.run'](cmd)
    return ret

    刷新

    salt '*' saltutil.sync_modules

    会把文件刷新到minion端

     /var/cache/salt/minion/extmods/

    执行

    salt '*' my_disk.list

                     

  • 相关阅读:
    nodejs之express路由与动态路由
    nodejs之mongodb操作
    nodejs之路由
    nodejs之简单应用与运行
    nodejs之fs 模块
    nodejs 之简单web服务器
    C++之结构体struct
    STL之stack
    【剑指offer】05替换空格,C++实现
    【剑指offer】04A二维数组中的查找,C++实现
  • 原文地址:https://www.cnblogs.com/sky00747/p/8258744.html
Copyright © 2011-2022 走看看