Removing Hosts from Stored Configurations

Once a host which has been integrated into Puppet along with stored configurations is removed again from Puppet, it has to be removed from the MySQL database which holds the data of the stored configurations as well. There’s no automatic deletion.

This is not a big issue, but it might be interesting for those not familiar with MySQL or for those just want to have a quick solution.

Login to MySQL

[root@somehost ~]# mysql -u puppet -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g. 
Your MySQL connection id is 38160
Server version: 5.0.77 Source distribution

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql>

Switch the database

mysql> use puppet;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> 

Get the host’s ID.

mysql> select id,name from hosts where name like 'myhost%';
+----+--------------------------+
| id | name                     |   
+----+--------------------------+
| 40 | myhost.somedomain.net | 
+----+--------------------------+
1 row in set (0.00 sec)

mysql>

Delete the host’s resources using its ID.

mysql> delete from resources where host_id=40;
Query OK, 331 rows affected (0.14 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> 

Delete the host.

mysql> delete from hosts where id=40;
Query OK, 1 row affected (0.02 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql>

Leave MySQL

mysql> quit
Bye
[root@somehost ~]#

That’s it.

, ,

No comments yet.

Leave a Reply

* Copy This Password *

* Type Or Paste Password Here *