I've been chasing a solution to this bug:
http://projects.theforeman.org/issues/5012
Bearing in mind I have little to no puppet background, I wanted to solicit
some ideas before I try reporting this upstream against the puppet
postgresql module.
First discovery was that use of ~> resource chaining was involved, for
example to get rid of the candlepin role error, all I had to do was change
line 88 here from ~> to ->, implying that candlepin::config should not
tell candlepin::database to refresh itself if the config changes.
https://github.com/Katello/katello-installer/blob/master/modules/candlepin/manifests/init.pp#L88
However in PR I discovered that this is not a suitable fix as it may cause
services to stop getting restarted on config changes.
Since then I've been trying to track down why the problem only appears with
notification chaining. I have established that deleting the database/role
and re-running the installer does not cause the issue, but also deleting
a candlepin config file will cause the issue. I.e. my quickest reproducer:
service tomcat6 stop && su - postgres -c 'dropdb candlepin' && su -
postgres -c "psql -c 'drop user candlepin'" && rm -f /etc/tomcat6/server.xml
katello-devel-installer --user=dgoodwin --group=dgoodwin
–deployment-dir=/home/dgoodwin -v -d
With some extensive logging added into the puppet postgresql module I see
something like this:
http://fpaste.org/97055/98454560/
I can simplify the output but basically the problem (and difference between
this and a successful run) starts at line #14 in the second paste above
when we see refresh called, which is found here:
Immediately I am confused as to why the resource is run once, then refresh
is run, I would assume that puppet is going to combine the two into one
pass.
So my first question, does that behaviour sound like sane puppet behaviour?
We appear to have a resource created once, run, then refreshed.
I'm assuming the answer to that is yes because perhaps refresh does some
special things, and puppet is doing the right thing. At that point I am
suspecting the bug exists here:
command() is called only once in this scenario, it correctly checks the
unless, sees the role does not exist, and proceeds to call command=(). The
command runs, then postgresql_psql.rb triggers refresh, which calls sync,
which ends up calling command=() again, but unless condition has already
been checked.
So I am wondering if command=() should be the point at which unless is
checked?
Any help greatly appreciated, I suspect this is very close to where the
issue is but expertise lacking to figure out how to fix. Opening the issue
upstream might be an option but would love to know if others agree this
appears to be the issue first.
Thanks,
Devan