Salt execution results returned to MySQL

Source: Internet
Author: User
Tags saltstack

what databases can be stored: https://docs.saltstack.com/en/latest/ref/returners/all/index.html

use MySQL as an example to configure the reference:

Https://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.mysql.html#module-salt.returners.mysql


Installing MySQL Mysql-python

[[email protected] salt]# yum install-y mysql-server mysql installation MySQL

[email protected] ~]# Yum install-y mysql-python # All minion have to pack the bag

[[email protected] ~]#/etc/init.d/mysqld start

[email protected] ~]# Yum install-y Mysql-python


Create A Salt library and jids, salt_events, Salt_returns three tables

[[email protected] ~]# MySQL

CREATE DATABASE ' Salt '

DEFAULT CHARACTER SET UTF8

DEFAULT COLLATE utf8_general_ci;

Use ' salt ';

CREATE TABLE ' Jids ' (

' Jid ' varchar (255) is not NULL,

' Load ' mediumtext not NULL,

UNIQUE KEY ' Jid ' (' Jid ')

) Engine=innodb DEFAULT Charset=utf8;

CREATE TABLE ' Salt_returns ' (

' Fun ' varchar (+) not NULL,

' Jid ' varchar (255) is not NULL,

' Return ' Mediumtext not NULL,

' ID ' varchar (255) is not NULL,

' Success ' varchar () 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;

CREATE TABLE ' salt_events ' (

' ID ' BIGINT not NULL auto_increment,

' Tag ' varchar (255) Not NULL,

' Data ' mediumtext not NULL,

' Alter_time ' TIMESTAMP DEFAULT current_timestamp,

' master_id ' varchar (255) is not NULL,

PRIMARY KEY (' id '),

KEY ' tag ' (' tag ')

) Engine=innodb DEFAULT Charset=utf8;


Create a user and authorize

GRANT all on salt.* to ' salt ' @ ' percent ' identified by ' salt ';

Flush privileges;


Remote login Test

[Email protected] ~]# mysql-h 192.168.10.129-usalt-psalt

Mysql>

  

Law One: The method is written directly to MySQL by minion data

[Email protected] ~]# vim/etc/salt/minion

[Email protected] ~]# tail/etc/salt/minion

#return: MySQL

Mysql.host: ' 192.168.10.129 '

Mysql.user: ' Salt '

Mysql.pass: ' Salt '

Mysql.db: ' Salt '

mysql.port:3306

[Email protected] ~]#/etc/init.d/salt-minion restart

[Email protected] ~]# vim/etc/salt/minion

[Email protected] ~]# tail/etc/salt/minion

#return: MySQL

Mysql.host: ' 192.168.10.129 '

Mysql.user: ' Salt '

Mysql.pass: ' Salt '

Mysql.db: ' Salt '

mysql.port:3306

[Email protected] ~]#/etc/init.d/salt-minion restart

[[email protected] ~]# Salt ' * ' test.ping--return MySQL

Mysql> select * from Salt_returns;

Law II: The method is configured directly on Master , andthe Minion end returns the information to the cache of master and writes the database from the cache information

[Email protected] ~]# Vim/etc/salt/master

[Email protected] ~]# Tail/etc/salt/master

Master_job_cache:mysql

Mysql.host: ' 192.168.10.129 '

Mysql.user: ' Salt '

Mysql.pass: ' Salt '

Mysql.db: ' Salt '

mysql.port:3306

[Email protected] ~]#/etc/init.d/salt-master restart

[[email protected] ~]# Salt ' * ' Cmd.run ' df-h '

Mysql> select * from Salt_returns;


This article is from the "Feng" blog, make sure to keep this source http://fengxiaoli.blog.51cto.com/12104465/1957998

Salt execution results back to MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.