设为首页 收藏本站
查看: 1171|回复: 0

[经验分享] saltstack salt 命令用法以及模块(二)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-1-12 08:32:10 | 显示全部楼层 |阅读模式
                      [iyunv@master ~]# salt --help   
Usage: salt   [options]    '<target>'    <function>     [arguments]
  Options:   
  --version             show program's version number and exit
  
   [iyunv@master ~]# salt --version        
salt 2015.5.5 (Lithium)

     
  --versions-report     show program's dependencies version number and exit
  
   [iyunv@master ~]# salt --versions-report    输出相关的依赖包版本号        
           Salt: 2015.5.5         
         Python: 2.6.6 (r266:84292, Jul 23 2015, 14:41:34)         
         Jinja2: unknown         
       M2Crypto: 0.20.2         
msgpack-python: 0.4.6         
   msgpack-pure: Not Installed         
       pycrypto: 2.0.1         
        libnacl: Not Installed         
         PyYAML: 3.10         
          ioflo: Not Installed         
          PyZMQ: 14.3.1         
           RAET: Not Installed         
            ZMQ: 3.2.5         
           Mako: 0.3.4         
        Tornado: Not Installed         
        timelib: Not Installed         
       dateutil: Not Installed

    -c CONFIG_DIR, --config-dir=CONFIG_DIR   Pass in an alternative configuration directory.   Default: /etc/salt   进入一个指定的配置文件目录      
  -t TIMEOUT, --timeout=TIMEOUT   Change the timeout, if applicable, for the running command; default=5  设置命令运行的超时时间      
-s, --static          Return the data from minions as a group after they all  return.   等组中的所有的minion都运行完毕才返回执行结果        
  -p, --progress        Display a progress graph. [Requires `progressbar` python package.]

  
   [iyunv@master progressbar-2.3]# salt -p centos_minion_01 cmd.run "uptime"        
100% |#########################################| Elapsed Time: 0:00:00 Returns: [1/1]

    -------------------------------------------        
Summary         
-------------------------------------------         
# of Minions Targeted: 1         
# of Minions Returned: 1         
# of Minions Did Not Return: 0         
-------------------------------------------

       
  --failhard            Stop batch execution upon first "bad" return      
  --async               Run the salt command but don't wait for a reply      
  --subset=SUBSET       Execute the routine on a random subset of the targeted      
                        minions. The minions will be verified that they have      
                        the named function before executing      
  -v, --verbose         Turn on command verbosity, display jid and active job      
                        queries      
  --hide-timeout        Hide minions that timeout      
  --show-jid            Display jid without the additional output of --verbose      
  -b BATCH, --batch=BATCH, --batch-size=BATCH      
                        Execute the salt job in batch mode, pass either the      
                        number of minions to batch at a time, or the      
                        percentage of minions to have running      
  -a EAUTH, --auth=EAUTH, --eauth=EAUTH, --external-auth=EAUTH      
                        Specify an external authentication system to use.      
  -T, --make-token      Generate and save an authentication token for re-use.      
                        The token is generated and made available for the      
                        period defined in the Salt Master.      
  --return=RETURNER     Set an alternative return method. By default salt will      
                        send the return data from the command back to the      
                        master, but the return data can be redirected into any      
                        number of systems, databases or applications.      
  --return_config=RETURNER_CONF      
                        Set an alternative return method. By default salt will      
                        send the return data from the command back to the      
                        master, but the return data can be redirected into any      
                        number of systems, databases or applications.      
  -d, --doc, --documentation      
                        Return the documentation for the specified module or      
                        for all modules if none are specified.      
  --args-separator=ARGS_SEPARATOR      
                        Set the special argument used as a delimiter between      
                        command arguments of compound commands. This is useful      
                        when one wants to pass commas as arguments to some of      
                        the commands in a compound command.      
  --summary             Display summary information about a salt command      
  --username=USERNAME   Username for external authentication      
  --password=PASSWORD   Password for external authentication      
  --metadata=METADATA   Pass metadata into Salt, used to search jobs.

    Logging Options:      
    Logging options which override any settings defined on the      
    configuration files.

      -l LOG_LEVEL, --log-level=LOG_LEVEL      
                        Console logging log level. One of 'all', 'garbage',      
                        'trace', 'debug', 'info', 'warning', 'error',      
                        'critical', 'quiet'. Default: 'warning'.      
    --log-file=LOG_FILE      
                        Log file path. Default: /var/log/salt/master.      
    --log-file-level=LOG_LEVEL_LOGFILE      
                        Logfile logging log level. One of 'all', 'garbage',      
                        'trace', 'debug', 'info', 'warning', 'error',      
                        'critical', 'quiet'. Default: 'warning'.

    Target Options:      
    Target Selection Options

      -E, --pcre          Instead of using shell globs to evaluate the target      
                        servers, use pcre regular expressions      
    -L, --list          Instead of using shell globs to evaluate the target      
                        servers, take a comma or space delimited list of      
                        servers.      
    -G, --grain         Instead of using shell globs to evaluate the target      
                        use a grain value to identify targets, the syntax for      
                        the target is the grain key followed by a      
                        globexpression: "os:Arch*"      
    --grain-pcre        Instead of using shell globs to evaluate the target      
                        use a grain value to identify targets, the syntax for      
                        the target is the grain key followed by a pcre regular      
                        expression: "os:Arch.*"      
    -N, --nodegroup     Instead of using shell globs to evaluate the target      
                        use one of the predefined nodegroups to identify a      
                        list of targets.      
    -R, --range         Instead of using shell globs to evaluate the target      
                        use a range expression to identify targets. Range      
                        expressions look like %cluster      
    -C, --compound      The compound target option allows for multiple target      
                        types to be evaluated, allowing for greater      
                        granularity in target matching. The compound target is      
                        space delimited, targets other than globs are preceded      
                        with an identifier matching the specific targets      
                        argument type: salt 'G@os:RedHat and webser* or      
                        E@database.*'      
    -I, --pillar        Instead of using shell globs to evaluate the target      
                        use a pillar value to identify targets, the syntax for      
                        the target is the pillar key followed by a glob      
                        expression: "role:production*"      
    -J, --pillar-pcre   Instead of using shell globs to evaluate the target      
                        use a pillar value to identify targets, the syntax for      
                        the target is the pillar key followed by a pcre      
                        regular expression: "role:prod.*"      
    -S, --ipcidr        Match based on Subnet (CIDR notation) or IPv4 address.

    Additional Target Options:      
    Additional Options for Minion Targeting

      --delimiter=DELIMITER      
                        Change the default delimiter for matching in multi-      
                        level data structures. default=':'

    Output Options:      
    Configure your preferred output format

      --out=OUTPUT, --output=OUTPUT      
                        Print the output from the 'salt' command using the      
                        specified outputter. The builtins are 'key', 'yaml',      
                        'overstatestage', 'txt', 'newline_values_only',      
                        'no_return', 'raw', 'virt_query', 'compact', 'json',      
                        'highstate', 'nested', 'quiet', 'pprint'.      
    --out-indent=OUTPUT_INDENT, --output-indent=OUTPUT_INDENT      
                        Print the output indented by the provided value in      
                        spaces. Negative values disables indentation. Only      
                        applicable in outputters that support indentation.      
    --out-file=OUTPUT_FILE, --output-file=OUTPUT_FILE      
                        Write the output to the specified file      
    --out-file-append, --output-file-append      
                        Append the output to the specified file      
    --no-color, --no-colour      
                        Disable all colored output      
    --force-color, --force-colour      
                        Force colored output      
    --state-output=STATE_OUTPUT, --state_output=STATE_OUTPUT      
                        Override the configured state_output value for minion      
                        output. One of full, terse, mixed, changes or filter.      
                        Default: full.

  You can find additional help about salt issuing "man salt" or on      
http://docs.saltstack.org

    例子:
  [iyunv@master ~]# salt  '*'  test.ping      
centos_minion_01:      
    True

  
  [iyunv@master ~]# salt  centos_minion_01 cmd.run "ifconfig"   
centos_minion_01:     
    eth0      Link encap:Ethernet  HWaddr 00:0C:29:12:8F:F4  
              inet addr:192.168.0.39  Bcast:192.168.0.255  Mask:255.255.255.0     
              inet6 addr: fe80::20c:29ff:fe12:8ff4/64 Scope:Link     
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1     
              RX packets:37845 errors:0 dropped:0 overruns:0 frame:0     
              TX packets:3230 errors:0 dropped:0 overruns:0 carrier:0     
              collisions:0 txqueuelen:1000     
              RX bytes:2588281 (2.4 MiB)  TX bytes:350375 (342.1 KiB)     
              Interrupt:19 Base address:0x2000     
   
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0     
              inet6 addr: ::1/128 Scope:Host     
              UP LOOPBACK RUNNING  MTU:65536  Metric:1     
              RX packets:135 errors:0 dropped:0 overruns:0 frame:0     
              TX packets:135 errors:0 dropped:0 overruns:0 carrier:0     
              collisions:0 txqueuelen:0     
              RX bytes:7740 (7.5 KiB)  TX bytes:7740 (7.5 KiB)
                   


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-163252-1-1.html 上篇帖子: Saltstack的pillar组件(6) 下篇帖子: 系统自动化配置和管理工具:SaltStack
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表