Ask Your Question
0

How to insert row into RDBMS table from puppet module?

asked 2013-12-09 21:13:35 -0500

Red Cricket gravatar image

updated 2013-12-09 21:14:32 -0500

I have a database table where I need to insert a row for each host has been assigned a particular puppet model. Lets call this puppet model foo. The db table is called foo_hosts has three columns: id, hostname, and date_added. I would like to some how have my foo module execute SQL ...

insert into foo_hosts (hostname) values ( $hostname );

... if there is not already a row in the table for the host.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-04-26 20:04:46 -0500

Just off the cuff, I'd suggest using exec with your database's command line tools. I've used many different databases and they all have a way to execute a SQL script from the command line. If you're using mySQL, these links may give you some ideas.

https://ask.puppetlabs.com/question/3... https://ask.puppetlabs.com/question/2...

Regards,

Kurt

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-12-09 21:13:35 -0500

Seen: 240 times

Last updated: Apr 26 '15