zoukankan      html  css  js  c++  java
  • python运维之saltstack方式

    # 1. 安装saltstack
    #       rpm --import https://repo.saltstack.com/yum/redhat/6/x86_64/latest/SALTSTACK-GPG-KEY.pub
    #
    #
    """
            Master: yum install salt-master
           Master准备:
                a. 配置文件,监听本机IP
                    vim /etc/salt/master
                    interface: 本机IP地址
                b. 启动master
                    /etc/init.d/salt-master start
    
    
            Slave:  yum install salt-minion
            Slave准备:
                a. 配置文件,连接那个master
                    vim /etc/salt/minion
                    master: 远程master地址
                b. 启动slave
                    /etc/init.d/salt-minion start
    
    2. 创建关系
        查看
        Master:salt-key -L
            Accepted Keys:
            Denied Keys:
            Unaccepted Keys:
                c1.com
                c2.com
                c3.com
            Rejected Keys:
        接受
        Master:salt-key -a c1.com
            Accepted Keys:
                c1.com
                c2.com
            Denied Keys:
            Unaccepted Keys:
                c3.com
            Rejected Keys:
    
    
    3. 执行命令
        master:
            salt 'c1.com' cmd.run  'ifconfig'
    
        import salt.client
        local = salt.client.LocalClient()
        result = local.cmd('c2.salt.com', 'cmd.run', ['ifconfig'])
    
    """
    # ################## 获取今日未采集主机名 ##################
    #result = requests.get('http://www.127.0.0.1:8000/assets.html')
    # result = ['c1.com','c2.com']
    
    
    # ################## 远程服务器执行命令 ##################
    # import subprocess
    # result = subprocess.getoutput("salt 'c1.com' cmd.run  'ifconfig'")
    #
    # import salt.client
    # local = salt.client.LocalClient()
    # result = local.cmd('c2.salt.com', 'cmd.run', ['ifconfig'])
    
    
    # ##################  发送数据 ##################
    # requests.post('http://www.127.0.0.1:8000/assets.html',data=data_dict)
  • 相关阅读:
    【中山纪念中学六年级模拟赛】方格翻转 题解
    高斯消元
    net 控件开发资料
    使用自定义验证组件库扩展 Windows 窗体
    POJ 3032
    UVa 10878 Decode the tape
    C语言I博客作业03
    第十周助教总结
    第十二周助教总结
    C语言I博客作业06
  • 原文地址:https://www.cnblogs.com/GodLv/p/9842351.html
Copyright © 2011-2022 走看看