job管理:

1.master在下发指令任务时,会附带上产生的jid。
2.minion在接收到指令开始执行时,会在本地的/var/cache/salt/minion/proc目录下产生该jid命名的文件,用于在执行过程中master查看当前任务的执行情况。
3.指令执行完毕将结果传送给master后,删除该临时文件。

Job缓存默认保存24小时

[[email protected] salt]# cd /var/cache/salt/master/jobs/

SALTSTACK(下)

[[email protected] jobs]# yum install -y mysql

SALTSTACK(下)

[[email protected] jobs]# yum install -y mariadb.server

[[email protected] mnt]# systemctl start mariadb.service

[[email protected] mnt]# mysql

MariaDB [(none)]> show databases;

SALTSTACK(下)

[[email protected] ~]# yum install -y MySQL-python.x86_64

SALTSTACK(下)

[[email protected] ~]# cd /etc/salt/
[[email protected] salt]# vim minion

SALTSTACK(下)

[[email protected] salt]# systemctl restart salt-minion.service

[[email protected] ~]# vim add.sql

SALTSTACK(下)

SALTSTACK(下)

SALTSTACK(下)

[[email protected] ~]# mysql < add.sql      ##导入

[[email protected] ~]# mysql

MariaDB [(none)]> show databases;

MariaDB [(none)]> use salt

MariaDB [salt]> show tables;

SALTSTACK(下)

[[email protected] ~]# mysql

MariaDB [(none)]> grant all on salt.* to [email protected] identified by 'salt';

MariaDB [(none)]> grant all on salt.* to [email protected]'%' identified by 'salt';

SALTSTACK(下)

[[email protected] ~]# mysql -u salt -p salt

SALTSTACK(下)

[[email protected] ~]# salt server2 cmd.run hostname

SALTSTACK(下)

[[email protected] ~]# mysql

MariaDB [salt]> show tables;

MariaDB [salt]> select * from salt_returns;

SALTSTACK(下)

配置master端:

[[email protected] salt]# vim minion

SALTSTACK(下)

[[email protected] ~]# vim /etc/salt/master

SALTSTACK(下)

[[email protected] ~]# systemctl restart salt-master.service

[[email protected] ~]# yum install -y MySQL-python.x86_64

[[email protected] ~]# salt '*' test.ping

SALTSTACK(下)

[[email protected] ~]# mysql

MariaDB [(none)]> use salt

MariaDB [salt]> show tables;

MariaDB [salt]> select * from salt_returns;

SALTSTACK(下)

相关文章: