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

    Runner 模块

    在master端执行的 salt-run

    Module 模块

    通过master同步到minion端, 在minion执行

    salt-call saltutil.sync_modules
    salt-call saltutil.sync_all:包括:beacons:
    clouds: engines: grains: log_handlers: modules:
    output: proxymodules: renderers: returners: sdb:
    states: utils:      

    Grins 模块

    记录minion的属性key:value

    Pillar模块

    记录所有minion通用的属性,然后同步到minion端

    salt-call saltutil.refresh_pillar
    salt ‘*’ saltutil.refresh_pillar

    cmd模块 

    salt ‘*’ cmd.run “df -h”

    ping模块  

    salt ‘*’ test.ping –t 5

    cp 模块

    file_roots:
      base:
       - /export/salt/root
       salt根目录:在master中file_roots定义的路径,salt://test.txt相当于/export/salt/root/test.txt
       salt 'wms5test1.app.172.17.23.176' cp.get_file salt://nscd.conf /tmp/xiang.txt

    cron模块

    salt '*' cron.raw_cron root (查看定时任务)
    salt '*' cron.set_job root '*' '*' '*' '*' 1 /export/scripts/rm_log.sh
    salt '*' cron.rm_job root /export/scripts/rm_log.sh (写全没效果)

    dnsutil模块

    salt '*' dnsutil.hosts_append /etc/hosts 127.0.0.1 xiang.com
    salt '*' dnsutil.hosts_remove /etc/hosts xiang.com

    file模块

    salt '*' file.chown /etc/passwd root root
    salt '*' file.copy /path/to/src /path/to/dst
    salt '*' file.file_exists /etc/hosts
    salt '*' file.directory_exists /etc/
    salt '*' file.get_mod /etc/passwd
    salt '*' file.set_mod /etc/passwd 0644
    salt '*' file.mkdir /tmp/test
    salt '*' file.sed /export/servers/nginx/conf/nginx.conf 'debug' 'warn'
    salt '*' file.append /tmp/test.txt "welcome xiang"
    salt '*' file.remove /tmp/1.txt

    network模块

    salt '*' network.dig www.qq.com
    salt '*' network.ping www.qq.com
    salt '*' network.ip_addrs 

    pkg包管理模块

    管理yum, apt-get等
      salt '*' pkg.install php
      salt '*' pkg.remove php
      salt '*' pkg.upgrade (升级所有的软件包)   

    service模块

    salt '*' service.enable nginx
    salt '*' service.disable nginx
    salt '*' service.restart nginx

    Grains模块

    自定义grians(在minion上定义的)
    grains是在minion启动时搜集一些信息,如操作系统类型,网卡,内核版本,cpu架构等
    salt "*" grains.ls 列出所有grains项目名字
    salt "*app.*" grains.items 列出所有grains项目以及值
    grains的信息并不是动态的,并不会实时变化,它只是在minion启动时收集到的
    我们可以根据grains收集到的一些信息,做一些配置管理工作
    在minion上:vim /etc/salt/grains
          role: nginx
          env: test
    重启service salt-minion restart
    获取grians:
    salt "*" grains.item role env
    或者:
    salt -G "*" role:nginx cmd.run "hostname“
    salt ‘*’grains.items     

    Pillar模块

    pillar(在master上定义)(yaml语法)
    在配置文件中找pillar的文件路劲:
    找到以后,mkdir /export/salt/pillar
    vim top.sls
    base:
     "*":
      - test
    vim test.sls
     conf: xiang
    
    然后刷新pillar: salt '*' saltutil.refresh_pillar
    验证:salt '*' pillar.items conf
    或者: salt -I 'conf:xiang' test.ping

     

  • 相关阅读:
    C# XmlSerializer实现序列化浅析(转载)
    Direct3D学习(资料收集)
    幸福法则
    javascript中的keydown事件中的参数问题
    去除UTF8 BOM【转】
    JavaScript常用资料参考
    KCFinder CKEditor的文件管理器插件
    elFinder Web文件管理器
    用TcpTrace调试Web服务器
    Ubuntu 12.04如何登入root?
  • 原文地址:https://www.cnblogs.com/Tang-Yuan/p/14388759.html
Copyright © 2011-2022 走看看