Ask Your Question

Provisioning PosgreSQL with Puppet on Vagrant

asked 2013-10-25 04:50:25 -0600

andresclari gravatar image

I've got a puppet manifest that resists my attempts to get it working right, given I'm no expert on the puppet DSL, and I'm fairly new to Puppet, I haven't managed to figure this out.

I'm trying to install Postgres using puppetlabs posgres module, creating a default role, and fixing up the DBs to work on UTF8.

Everything runs and installs, but the role doesn't get created. But if I run the provision again, then the role gets created. I assume perhaps has to do with the execution order, but honestly I'm lost ... (more)

edit retag flag offensive close merge delete


Lol - you're creating a role, then dropping the entire cluster and recreating it in the exec .... erm. Yes, you have a massive ordering issue :-). Read the man page for pg_dropcluster.

ken gravatar imageken ( 2013-11-01 08:27:40 -0600 )edit

also why don't you let the postgresql module handle the installation of the packages ?

golja gravatar imagegolja ( 2013-11-10 04:30:45 -0600 )edit

Because that's what triggers the DB being created in ASCII encoding, that's what I was doing at first, but due to the bug on puppet, this is the ...(more)

andresclari gravatar imageandresclari ( 2013-11-10 04:47:21 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2013-10-25 23:48:50 -0600

spuder gravatar image

Try running your puppet module with debug, it may give additional insight to what is happening.

puppet apply foo --debug

One possible issue I see is that you are making a user called 'user_vagrant'. I assume you actually just want to make sure the vagrant user exits, not make a new user.

You have:

user { "user_vagrant":
  ensure => "present",

I assume you want

user { 'vagrant':
  ensure => "present",

Also, I recommend that you make sure you have the latest version of puppet, (3.x).

edit flag offensive delete link more


right about that, I changed it so many times, I made a mistake last time I added it.

andresclari gravatar imageandresclari ( 2013-10-29 06:40:33 -0600 )edit

answered 2013-10-25 13:25:25 -0600

nibalizer gravatar image

I spun up a vagrant mahcine (precise64) to test this out. The Puppet code is all solid. As far as I can tell the problem is the arrow chaining the vagrant role to the exec. The exec is not firing in my test suite, probably because the unless condition is not being satisfied. When I comment out the exec or remove the arrow chaining syntax the vagrant role is created.

puppet apply --test pg.pp
Notice: /Stage[main]/Postgresql::Server::Reload/Exec[postgresql_reload]: Triggered 'refresh' from 1 events
Notice: /Stage[main]/Postgresql::Server::Service/Service[postgresqld]: Triggered 'refresh' from 1 ...
edit flag offensive delete link more


I tried removing the -> linking the role to the exec. and so far seems to work ok, however my box is not finding some packages from the full setup right ...(more)

andresclari gravatar imageandresclari ( 2013-10-29 06:42:52 -0600 )edit

answered 2013-11-09 20:50:30 -0600

andresclari gravatar image

Finally found the right approach to fix both the applied order, and the UTF8 issue which forced me to try the "pg_dropcluster" to begin with. Btw, this is a known issue here's the issue url

This is the whole file I use to install PostgreSQL 9.1 with UTF8, and RVM ruby. Hope this helps.

- puppetlabs/apt - 1.4
- puppetlabs/concat - 1.0
- puppetlabs/stdlib - 4.1.0
- puppetlabs/postgresql - 3.2
- blt04/puppet-rvm - git://

stage { 'pre':
  before => Stage['main']

class pre_req {
  user { "vagrant":
    ensure => "present",

  exec ...
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-10-25 04:50:25 -0600

Seen: 490 times

Last updated: Nov 09 '13