Get the App
SLTechnology News&Howtos  ›  Database  › 

The execution result of saltstack is returned to mysql

Shulou Source: shulou.com Published: 2022-06-01 07:23:31 10月05日 Update

System: ubuntu 17.04

Official document https://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.mysql.html

Master

(salt-master, mysql,python2.7-mysql)

Syndic

(salt-master,mysql-client,salt-syndic,python2.7-mysql)

Minion

(salt-minion,mysql-client,python2.7-mysql)

Master

# cat / etc/salt/master | grep-v "#" | grep-v "^ * $"

Ipv6: False

Interface: 192.168.90.177

Auto_accept: True

State_top: top.sls

Order_masters: True

Return: mysql

# # mysql##

CREATE DATABASE salt

DEFAULT CHARACTER SET utf8

DEFAULT COLLATE utf8_general_ci

USE salt

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

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

DROP TABLE IF EXISTS salt_events

CREATE TABLE salt_events (

Id BIGINT NOT NULL AUTO_INCREMENT

Tag varchar (255) NOT NULL

Data varchar (1024) NOT NULL

Alter_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP

PRIMARY KEY (id)

KEY tag (tag)

) ENGINE=InnoDB DEFAULT CHARSET=utf8

Mysql > use salt

Mysql > show tables

+-+

| | Tables_in_salt |

+-+

| | jids |

| | salt_events |

| | salt_returns |

+-+

Grant all on salt.* to salt@'%' identified by 'salt'

(this is mysql on ubuntu)

Root@jy-KVM1:~# cat / etc/mysql/mysql.conf.d/mysqld.cnf | grep bind

# bind-address = 127.0.0.1 # comment out and allow other machines to access

#

Syndic

# cat / etc/salt/master | grep-v "#" | grep-v "^ * $"

Ipv6: False

Auto_accept: True

File_roots:

Base:

/ etc/salt/base

Prod:/etc/salt/prod

Syndic_master: 192.168.90.177

Minion

# cat / etc/salt/minion | grep-v "#" | grep-v "^ * $"

Master: 192.168.90.178

Id: 192.168.90.179

Mysql.host: '192.168.90.177'

Mysql.user: 'salt'

Mysql.pass: 'salt'

Mysql.db: 'salt'

Mysql.port: 3306

Execute on master

# salt'* 'test.ping

View the database

6. Row

Fun: test.ping

Jid: 20171204130021772990

Return: true

Id: 192.168.90.179

Success: 1

Full_ret: {"fun_args": [], "jid": "20171204130021772990", "return": true, "retcode": 0, "success": true, "fun": "test.ping", "id": "192.168.90.179"}

Alter_time: 2017-12-04 13:00:23

6 rows in set (0.01 sec)

ERROR:

No query specified

Mysql >

Tags: Official data database document machine comment system result Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Microsoft Huawei macOS MariaDB