Saltstack–using the Mysql Module

Source: Internet
Author: User
Tags saltstack

Salt ' * ' saltutil.refresh_pillar


The official website example really did not understand, the English dish. In fact, a simple step.


Reference documents

Https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.mysql.html

https://z900collector.wordpress.com/linux/using-the-saltstack-mysql-module/


Salt-master is mainly looking for/usr/lib/python2.6/site-packages/salt/modules/test.py.

[Email protected] salt]# cat/etc/salt/minion

master:172.1.1.1

Id:cm1

Mysql.host: ' localhost '

mysql.port:3306

Mysql.user: ' Root '

Mysql.socket: ' X.sock '

Mysql.pass: ' xx '

Mysql.charset: ' UTF8 '


/etc/init.d/salt-minion restart


‘‘‘

Execution order, test command

State.show_sls execute function to see the order of salt State execution

sudo salt stage-db1 state.show_sls mysql

sudo salt stage-db1 state.apply mysql test=true

sudo salt stage-db1 state.apply mysql


Mysql

sudo salt stage-db1 mysql.db_list

‘‘‘

Salt ' * ' mysql.db_list


The most complete example

Https://www.digitalocean.com/community/tutorials/saltstack-infrastructure-creating-salt-states-for-mysql-database-servers


1.salt-minion End

MySQL connection information/etc/salt/minion.d/mysql.conf

mysql.default_file: '/etc/mysql/salt.cnf'


Vim/etc/mysql/salt.cnf

Mysql.host: ' localhost '

mysql.port:3306

Mysql.user: ' Root '

Mysql.socket: ' X.sock '

Mysql.pass: ' xx '

Mysql.charset: ' UTF8 '


2.vim/srv/pillar/top.sls

Base

'[email protected]:d EV and [email protected]:d bserver':

-Match:compound

-Dev.mysql


' [Email protected]:stage and [email protected]:d bserver ':

-Match:compound

-Stage.mysql


' [email protected]:p rod and [email protected]:d bserver ':

-Match:compound

-Prod.mysql


3.vim/srv/salt/mysql/init.sls

Debconf-utils:

Pkg.installed


Mysql_setup:

Debconf.set:

-Name:mysql-server

-Data:

' Mysql-server/root_password ': {' type ': ' Password ', ' value ': ' {{salt[' pillar.get '] (' MYSQL:ROOT_PW ', ')}} '}

' Mysql-server/root_password_again ': {' type ': ' Password ', ' value ': ' {{salt[' pillar.get '] (' MYSQL:ROOT_PW ', ')}} '}

-Require:

-Pkg:debconf-utils


PYTHON-MYSQLDB:

Pkg.installed


Mysql-server:

Pkg.installed:

-Require:

-Debconf:mysql-server

-Pkg:python-mysqldb


Mysql:

Service.running:

-Watch:

-Pkg:mysql-server

-File:/etc/mysql/my.cnf


Mysql:

Service.running:

-Watch:

-Pkg:mysql-server

-File:/etc/mysql/my.cnf


/ETC/MYSQL/MY.CNF:

File.managed:

- Source:salt://mysql/files/etc/mysql/my.cnf.jinja

-Template:jinja

-User:root

-Group:root

-mode:640

-Require:

-Pkg:mysql-server


/etc/salt/minion.d/mysql.conf:

File.managed:

-Source: salt://mysql/files/etc/salt/minion.d/mysql.conf

-User:root

-Group:root

-mode:640

-Require:

-Service:mysql


/ETC/MYSQL/SALT.CNF:

File.managed:

- Source:salt://mysql/files/etc/mysql/salt.cnf.jinja

-Template:jinja

-User:root

-Group:root

-mode:640

-Require:

-Service:mysql


Restart_minion_for_mysql:

Service.running:

-Name:salt-minion

-Watch:

-File:/etc/salt/minion.d/mysql.conf


Above is an example on the Digitoean cloud. The most important thing is /ETC/SALT/MINION.D .

This article from "Want to have a dream, in case the realization of" blog, declined reprint!

Saltstack–using the Mysql Module

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.