Ask Your Question

How to insert row into RDBMS table from puppet module?

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

Red Cricket gravatar image

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

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

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

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.



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


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

Seen: 336 times

Last updated: Apr 26 '15