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' ...
Get Salt Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.