SlatStack安装配置

一、环境准备

slat-master-1:10.0.241.122

# yum install salt-master -y
# systemctl start salt-master.service

salt-minion-1:10.0.241.123

salt-minion-2:10.0.241.124

# yum install salt-minion -y
# sed -i 's/#master: salt/master: 10.0.241.122/g' /etc/salt/minion
# systemctl start salt-minion.service
# echo `hostname` > /etc/salt/minion_id
# systemctl restart salt-minion.service

在salt-master上接受salt-minion的key

[root@salt-master-1 ~]# salt-key -yA
The following keys are going to be accepted:
Unaccepted Keys:
salt-minion-1
salt-minion-2
Key for minion salt-minion-1 accepted.
Key for minion salt-minion-2 accepted.

二、日常命令参数

Master端:

[root@salt-master-1 ~]# rpm -ql salt-master
/etc/salt/master                                   # salt master 配置文件
/usr/bin/salt                                      # salt master 核心操作命令
/usr/bin/salt-cp                                   # salt 文件传输命令
/usr/bin/salt-key                                  # salt 证书管理命令
/usr/bin/salt-master                               # salt master 服务命令
/usr/bin/salt-run                                  # salt master runner命令
/usr/bin/salt-unity                                # salt master
/usr/lib/systemd/system/salt-master.service        # salt master 服务启动脚本
[root@salt-master-1 ~]# salt -h
Usage: salt [options] '<target>' <function> [arguments]

Options:
  --version             查看SaltStack程序的版本号
  --versions-report     查看SaltStack程序以及依赖包的版本号
  -h, --help            查看帮助信息
  --saltfile=SALTFILE   Specify the path to a Saltfile. If not passed, one
                        will be searched for in the current working directory
  -c CONFIG_DIR, --config-dir=CONFIG_DIR
                        指定配置文件目录
                        Default: /etc/salt
  -t TIMEOUT, --timeout=TIMEOUT
                        指定Timeout实践
                        command; default=5
  --hard-crash          捕捉original异常不退出
                        gracefully Default: False
  -s, --static          以组的形式返回所有Minion的数据
  -p, --progress        Display a progress graph. [Requires `progressbar`
                        python package.]
  --failhard            Stop batch execution upon first "bad" return
  --async               异步执行
  --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            显示任务jid
  -b BATCH, --batch=BATCH, --batch-size=BATCH    按照百分比执行任务
  -a EAUTH, --auth=EAUTH, --eauth=EAUTH, --external-auth=EAUTH
                        指定外部认证方式
  -T, --make-token      生成Master token
  --return=RETURNER     指定SaltStack return
  --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    查看指定模块或所有模块文档
  --args-separator=ARGS_SEPARATOR    设置多个传参直接分隔符
  --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          正则匹配
    -L, --list          列表匹配
    -G, --grain         grains 匹配
    --grain-pcre        grains加正则匹配
                        expression: "os:Arch.*"
    -N, --nodegroup     组匹配
    -R, --range         范围匹配
    -C, --compound      综合匹配
                        matching the specific targets
                        argument type: salt 'G@os:RedHat and webser* or
                        E@database.*'
    -I, --pillar        pillar值匹配
                        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

Minion端:

[root@salt-minion-1 ~]# rpm -ql salt-minion
/etc/salt/minion                                   # salt minion 配置文件                  
/usr/bin/salt-call                                 # salt minion 拉取命令
/usr/bin/salt-minion                               # salt minion 服务命令
/usr/lib/systemd/system/salt-minion.service        # salt minion 服务启动脚本
[root@salt-minion-1 ~]# salt-call -h

Usage: salt-call [options] <function> [arguments]

Salt call is used to execute module functions locally on a minion

Options:
  --version             查看SaltStack程序的版本号
  --versions-report     查看SaltStack程序以及依赖包的版本号
  -h, --help            show this help message and exit
  --saltfile=SALTFILE   Specify the path to a Saltfile. If not passed, one
                        will be searched for in the current working directory
  -c CONFIG_DIR, --config-dir=CONFIG_DIR
                        Pass in an alternative configuration directory.
                        Default: /etc/salt
  --hard-crash          Raise any original exception rather than exiting
                        gracefully Default: False
  -g, --grains          返回的信息生成grains
  -m MODULE_DIRS, --module-dirs=MODULE_DIRS
                        指定自定义模块目录
                        Multiple directories can be provided by passing `-m
                        /--module-dirs` multiple times.
  -d, --doc, --documentation
                        查看指定模块或者所有模块文档
  --master=MASTER       Specify the master to use. The minion must be
                        authenticated with the master. If this option is
                        omitted, the master options from the minion config
                        will be used. If multi masters are set up the first
                        listed master that responds will be used.
  --return=RETURNER     Set salt-call to pass the return data to one or many
                        returner interfaces.
  --local               运行masterless模式
  --file-root=FILE_ROOT
                        指定file-root目录
  --pillar-root=PILLAR_ROOT
                        Set this directory as the base pillar root.
  --retcode-passthrough
                        Exit with the salt call retcode and not the salt
                        binary retcode
  --metadata            Print out the execution metadata as well as the
                        return. This will print out the outputter data, the
                        return code, etc.
  --id=ID               Specify the minion id to use. If this option is
                        omitted, the id option from the minion config will be
                        used.
  --skip-grains         Do not load grains.
  --refresh-grains-cache
                        Force a refresh of the grains cache
  -t AUTH_TIMEOUT, --timeout=AUTH_TIMEOUT
                        Change the timeout, if applicable, for the running
                        command; default=60

遇到的问题:

  1. salt-minion 中 /etc/salt/minion_id 文件里面的内容取的是服务器的fqdb,我在安装完salt-minion之后,看到salt-master上接受的minion为如下:

[root@salt-master-1 ~]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
VM_241_123_centos
VM_241_124_centos
Rejected Keys:

    执行如下命令:

# echo `hostname` > /etc/salt/minion_id
# systemctl restart salt-minion.service
[root@salt-master-1 ~]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
salt-minion-1
salt-minion-2
Rejected Keys:
[root@salt-master-1 ~]# salt  "salt-minion-*" test.ping
salt-minion-2:
    True
salt-minion-1:
    True


你可能感兴趣的:(SlatStack安装配置)