Remove a PuppetLabs Mysql DB

83 views
Skip to first unread message

Sergiu Cornea

unread,
Dec 10, 2015, 9:20:46 AM12/10/15
to Puppet Users
Hello guys,

I am not sure if this question has been asked, however I wasn't able to find something about it on Google, therefore, I am going to ask it here:

So, I have created 3 DBs using PuppetLabs MYSQL module, however, I don't know how to create the code to delete a database.

I have tried mysql::db { 'test': 
                           ensure => 'absent',
              }

but unfortunately it didn't worked, I've asked on the IRC channel and someone told me to use the 'destroy' function but I have no clue on how to use it, therefore, could someone point me in the right direction please?

Thank you,

Kind regards,
Sergiu

Joseph Karns

unread,
Dec 11, 2015, 12:14:39 PM12/11/15
to Puppet Users
Hello Sergiu:

The Puppet Labs MySQL Module creates the sql statements and runs them against the mysql server, but does not maintain them persistently. So to remove a database run the following
mysql -u <admin user> -p -h <hostname/ip> -e "DROP DATABASE <DB Name>"

Thanks
Joey

Martijn

unread,
Dec 21, 2015, 12:25:33 PM12/21/15
to Puppet Users
Hello Sergiu,

There is no need to run manual SQL code since the puppettlabs-mysql module has providers for this. I found an example being used in the puppetlabs-mysql module itself. See https://github.com/puppetlabs/puppetlabs-mysql/blob/master/manifests/server/account_security.pp

See the bottom of the file where the 'test' database is removed that is present by default on fresh MySQL installations.

Regards, Martijn

Op donderdag 10 december 2015 15:20:46 UTC+1 schreef Sergiu Cornea:
Reply all
Reply to author
Forward
0 new messages