zoukankan      html  css  js  c++  java
  • Linux saltstack常用模块

    所有模块

      salt '172.30.100.126' sys.list_modules  #列出当前版本支持的模块

      salt '*' sys.doc cp  #显示指定模块的文档

    archive模块

      实现系统层面的压缩包调用,支持gzip、gunzip、rar、tar、unrar、unzip等

    cmd模块

      实现远程的命令行调用执行

    salt '*' cmd.run 'df -h'
    # 执行传递的命令,并将结果作为字符串返回
    salt '*' cmd.script salt://tmp/test.sh
    # 从master端下载脚本,并在本地执行
    

    cp模块

      实现远程文件、目录的复制,以及下载URL文件等操作

    salt '*' cp.get_dir salt://path/to/dir/ /minion/dest
    # 从master递归复制指定目录到minion目录下
    salt '*' cp.get_file salt://path/to/file /minion/file
    从master复制单个文件到minion
    salt '*' cp.push /etc/hosts
    # 把minion端的文件推送到master端
    # 存放目录默认在/var/cache/salt/master/minions/minion-id/files
    salt '*' cp.push /usr/lib/mysql
    # 从minion端推送一个目录到master端
    

    cron模块

      实现被控主机的crontab操作

    salt '*' cron.raw_cron root
    # 返回指定用户的cron内容
    salt '*' cron.set_job root '*' '*' '*' '*' 1 /usr/local/weekly
    # 为指定用户添加一条cron任务
    salt '*' cron.rm_job root /usr/local/weekly
    # 为指定用户删除一条cron任务
    

    file模块

    salt '*' file.chown /etc/passwd root root
    # 修改文件的属主属组
    salt '*' file.copy /path/to/src /path/to/dst
    salt '*' file.copy /path/to/src_dir /path/to/dst_dir recurse=True remove_existing=True
    # 从src复制文件或目录到dst,可以递归复制,可以存在删除
    salt '*' file.move /path/to/src /path/to/dst
    # 移动指定文件或目录
    salt '*' file.rename /path/to/src /path/to/dst
    # 修改指定文件或目录的名称
    salt '*' file.file_exists /etc/hosts
    salt '*' file.directory_exists /etc
    # 检查指定文件或目录是否存在
    salt '*' file.stats /etc/hosts
    # 返回指定文件或目录的stats信息
    salt '*' file.mkdir /tmp/test
    # 不存在则创建,确保目录存在
    salt '*' file.remove /tmp/foo
    # 删除指定文件,如果是目录将被递归删除
    

      

  • 相关阅读:
    用c#开发微信 (7) 微渠道
    Swift语言精要
    Android开发点滴
    UITableViewAutomaticDimension
    iOS中ActionSheet和Alert的区别
    本博客申明
    iOS中重用UITableView单元格时,千万别忘了这个
    Swift 2 语言精要
    Objective-C中NSString与int和float的相互转换
    Android Studio常用快捷键
  • 原文地址:https://www.cnblogs.com/houyongchong/p/10136784.html
Copyright © 2011-2022 走看看