Using MySQL databases
In this recipe, you will learn how to create and remove databases in MySQL. You will also learn how to interrelate these definitions with other Salt definitions, and make all the database components work together.
How to do it...
We will use the same minion as the previous recipe.
Create and edit
/opt/salt-cookbook/staging/mysql/database.sls
to have the following entries:include: - mysql MySQL-python: pkg.installed stg_databases: mysql_database.present: - name: stagingdb - require: - pkg: MySQL-python - service: mysql_service databases_to_remove: mysql_database.absent: - name: test - require: - pkg: MySQL-python - service: mysql_service
Apply the state to the minion, using the following command:
[root@salt-master ~]# salt 'salt-minion-mysql' state.sls mysql.database saltenv=staging salt-minion-mysql: ---------- ID: mysql_package Function: pkg.installed Name: mysql-server Result: True Comment...