1. Job简介
2. master端Job缓存目录:
/var/cache/salt/master/jobs
[root@server4 ~]# yum install mariadb-server.x86_64 安装数据库
[root@server4 ~]# systemctl start mariadb.service
[root@server4 ~]# mysql_secure_installation
[root@server5 ~]# vim /etc/salt/minion
3.server4上测试
```sql
# cat add.sql
CREATE DATABASE `salt`
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
USE `salt`;
--
-- Table structure for table `jids`
--
DROP TABLE IF EXISTS `jids`;
CREATE TABLE `jids` (
`jid` varchar(255) NOT NULL,
`load` mediumtext NOT NULL,
UNIQUE KEY `jid` (`jid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- CREATE INDEX jid ON jids(jid) USING BTREE;
--
-- Table structure for table `salt_returns`
--
DROP TABLE IF EXISTS `salt_returns`;
CREATE TABLE `salt_returns` (
`fun` varchar(50) NOT NULL,
`jid` varchar(255) NOT NULL,
`return` mediumtext NOT NULL,
`id` varchar(255) NOT NULL,
`success` varchar(10) NOT NULL,
`full_ret` mediumtext NOT NULL,
`alter_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
KEY `id` (`id`),
KEY `jid` (`jid`),
KEY `fun` (`fun`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `salt_events`
--
4. 导入数据库
[root@server4 ~]# mysql -uroot -pwestos < add.sql 导入数据库
[root@server4 ~]# mysql -uroot -pwestos
MariaDB [(none)]> grant all on salt.* to salt@localhost identified by 'salt';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> grant all on salt.* to salt@'%' identified by 'salt';
Query OK, 0 rows affected (0.00 sec)
[root@server4 ~]# salt server5 cmd.run hostname
server5:
server5
salt-ssh可以独立运行的,不需要minion端。
salt-ssh 用的是sshpass进行密码交互的。
以串行模式工作,性能下降。
1. salt-ssh配置
停止minion端服务
[root@server5 ~]# systemctl stop salt-minion.service
安装salt-ssh:
[root@server4 ~]# yum install -y ssh-salt
[root@server4 ~]# cat /etc/salt/roster
# Sample salt-ssh config file
#web1:
# host: 192.168.42.1 # The IP addr or DNS hostname
# user: fred # Remote executions will be executed as user fred
# passwd: foobarbaz # The password to use for login, if omitted, keys are used
# sudo: True # Whether to sudo to root, not enabled by default
#web2:
# host: 192.168.42.2
server5:
host: 172.25.254.5
user: root
passwd: westos
server6:
host: 172.25.254.6
user: root
passwd: westos
1. salt-syndic配置
server4 172.25.254.4 salt-master
server5 172.25.254.5 salt-minion
server6 172.25.254.6 salt-minion
server7 172.25.254.7 salt-master(中心master)
1. salt-api配置
SaltStack 官方提供有REST API格式的 salt-api 项目,将使Salt与第三方系统集成变得尤为简单。
官方链接:https://docs.saltstack.com/en/latest/ref/netapi/all/index.html#all-netapi-modules
官方提供了三种api模块:
2. salt-api配置过程
安装
[root@server4 ~]# yum install -y salt-api python-cherrypy
[root@server4 master.d]# vim auth.conf
external_auth:
pam:
saltdev:
- .*
- '@wheel'
- '@runner'
- '@jobs'
创建用户
[root@server4 master.d]# useradd saltdev
[root@server4 master.d]# passwd saltdev
Changing password for user saltdev.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
激活rest_cherrypy模块
[root@server4 master.d]# vim cert.conf
[root@server4 master.d]# cat cert.conf
rest_cherrypy:
port: 8000
ssl_crt: /etc/pki/tls/certs/localhost.crt
ssl_key: /etc/pki/tls/private/localhost.key
[root@server4 master.d]# systemctl restart salt-master 重启
[root@server4 master.d]# systemctl start salt-api 启动
3. 获取认证token
[root@server4 master.d]# curl -sSk https://localhost:8000/login \
> -H 'Accept: application/x-yaml' \
> -d username=saltdev \
> -d password=westos \
> -d eauth=pam
return:
- eauth: pam
expire: 1591767118.761024
perms:
- .*
- '@wheel'
- '@runner'
- '@jobs'
- start: 1591723918.761023
token: bc00b70cb788756454e0db7eddf7fd4b47a3bb30
user: saltdev
[root@server4 master.d]# curl -sSk https://localhost:8000 \
> -H 'Accept: application/x-yaml' \
> -H 'X-Auth-Token: bc00b70cb788756454e0db7eddf7fd4b47a3bb30' \ token值是上面命令获取的toekn值
> -d client=local \
> -d tgt='*' \
> -d fun=test.ping