码迷,mamicode.com
首页 > 其他好文 > 详细

saltstack salt 命令用法以及模块(二)

时间:2016-01-12 06:40:18      阅读:564      评论:0      收藏:0      [点我收藏+]

标签:version

[root@master ~]# salt --help
Usage: salt   [options]    ‘<target>‘    <function>     [arguments]

Options:
  --version             show program‘s version number and exit

[root@master ~]# salt --version
salt 2015.5.5 (Lithium)


  --versions-report     show program‘s dependencies version number and exit

[root@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.]

[root@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

例子:

[root@master ~]# salt  ‘*‘  test.ping
centos_minion_01:
    True

 

[root@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)

saltstack salt 命令用法以及模块(二)

标签:version

原文地址:http://luzhi1024.blog.51cto.com/8845546/1733994

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!