zoukankan      html  css  js  c++  java
  • python saltstack

    1. 拷贝文件

    # salt ‘*‘ cp.get_file salt://first.xml /tmp/first.xml
    或 gzip=1-9,数字越大,压缩越高; makedirs=True 自动创建目录
    # salt ‘*‘ cp.get_file salt://first.xml /tmp/salt/first.xml gzip=9 makedirs=True

    2. 拷贝目录

    cp.get_dir,get_dir与get_file的用法十分相似,用来将整个目录分发到minions. 本例在master的/srv/salt下创建目录和文件:
    
    /srv/salt/hadoop_conf_dir/hadoop.config, 同步到所有minion节点的/tmp/hacl_conf下面, 如果目录不存在则创建,使用压缩
    
     
    
    # salt ‘*‘ cp.get_dir salt://hadoop_conf_dir /tmp/hacl_conf gzip=9 makedirs=True
    这样,minion上为:
     
    
    /tmp/hacl_conf/hadoop_conf_dir/hadoop.config

    3. salt接口实例调用

    3.1 salt.client

    import salt.client

    client = salt.client.LocalClient()

    ret = client.cmd('*','test.ping')

    print ret

    3.2 cmd

    1)功能:实现远程命令的调用执行

    2)实例:

    获取所有主机的内存使用情况 salt '*' cmd.run "free -m"

    #!/usr/bin/env python

    import salt.client
    client = salt.client.LocalClient()
    ret = client.cmd('minion-25.183','cmd.run',['df -hl'])
    print ret

  • 相关阅读:
    Java三年经验
    系统集成项目管理 - 笔记
    ZK
    older versions of the JRE and JDK
    [提高组集训2021] 古老的序列问题
    CF1556G Gates to Another World
    Codeforces Round #743 (Div. 1)
    [提高组集训2021] 蚂蚁
    [LOJ 6669] Nauuo and Binary Tree
    [ABC219H] Candles
  • 原文地址:https://www.cnblogs.com/fuckily/p/5817808.html
Copyright © 2011-2022 走看看