Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dginther
Created July 29, 2013 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dginther/6107901 to your computer and use it in GitHub Desktop.
Save dginther/6107901 to your computer and use it in GitHub Desktop.
Mysql state with password and mysql module config, and monit config.
mysql:
pkg:
- installed
- names:
- mysql-server
- mysql-server-5.5
- mysql-client
- require:
- pkg: python-mysqldb
- debconf: 'mysql-debconf'
service:
- enable: True
- running
- reload: True
- watch:
- file: /etc/mysql/my.cnf
- require:
- pkg: mysql
- file: /etc/salt/mysql_config
debconf-utils:
pkg:
- installed
python-mysqldb:
pkg:
- installed
#Debconf file for mysql
mysql-debconf:
debconf.set_file:
- source: salt://mysql/mysql-root.sel
- require:
- pkg: debconf-utils
/etc/mysql/my.cnf:
file.managed:
- source: salt://mysql/my.cnf
- mode: 644
- user: root
- group: root
- require:
- pkg: mysql
#Salt access to mysql for manipulating tables, etc.
/etc/salt/mysql_config:
file.managed:
- source: salt://mysql/mysql_config
- mode: 600
- user: root
- group: root
mysql-monit:
service:
- name: monit
- running
- reload: True
- watch:
- file: /etc/monit/conf.d/mysql.monit
mysql-minion:
service:
- name: salt-minion
- running
- reload: True
- watch:
- file: /etc/salt/mysql_config
/etc/monit/conf.d/mysql.monit:
file.managed:
- source: salt://mysql/mysql.monit
mysql-server mysql-server/root_password password password
mysql-server mysql-server/root_password_again password password
check process mysql with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/sbin/start mysql"
stop program = "/sbin/stop mysql"
if failed host 127.0.0.1 port 3306 protocol mysql then restart
if 5 restarts within 5 cycles then timeout
mysql.host: 'localhost'
mysql.port: 3306
mysql.user: 'root'
mysql.pass: 'password'
mysql.db: 'mysql'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment