Apart from managing configuration tasks in MySQL, Salt enables us to run SQL queries on databases using appropriate modules, in turn, providing us with a lot of flexibility for database management. In this recipe, you will learn how to run queries on MySQL databases using Salt.
We will use the same minion as the previous recipe.
/opt/salt-cookbook/staging/mysql/query.slsto have the following entries:
include: - mysql.database
mysql_query.run: - database: stagingdb - query: "create table first_table(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100) NOT NULL, PRIMARY KEY ( id ));" - output: "/tmp/create_first_table.txt" - require: - mysql_database: stg_databases