On Wednesday 24 Feb 2010 20:59:54 Andrew Hamilton wrote:
> I have a question hopefully someone here can help me out with. I have a
> module that I didn't write, I got it from the github. it's the postgres
> module. I'm running on CentOS 5. In the module there is this:
>
> case $ensure {
> present: {
> exec { "Create $name postgres db":
> command => "/usr/bin/createdb $ownerstring $name",
> user => "postgres",
> unless => "/usr/bin/psql -l | grep '$name *|'" *** This
> line causes an error
> }
> }
>
> The *** line causes puppet to error out like so:
>
> debug: //Node[myhost.mydomain.com]/Postgres::Role[voiceob]/Exec[Create
> puser postgres role]: Executing check '/usr/bin/psql -c '\du' | grep
> 'puser *|'' debug: Executing '/usr/bin/psql -c '\du' | grep 'puser *|''
> err: //Node[myhost.mydomain.com]/Postgres::Role[puser]/Exec[Create puser
> postgres role]: Failed to retrieve current state of resource:
>
> (This produces no output if the user doesn't exist in postgres.)
>
> Nothing more on the error line. Interestingly enough, if I remove the '|'
> (pipe) after the psql part of the command, it doesn't error. However, it
> doesn't do what I need it to do. I have tried it without the unless line
> and it works perfectly. Again, it doesn't do what I need it to do that way
> though. I have searched the message boards and wiki to no avail.
>
> Can any of you shed some light on why this wouldn't work?
>
> TIA
>
> Drew
>
I'm not sure why that doesn't work but I remember some problems I had with
psql in postgres setup, I think I eventually started changing the output
format to something different, e.g. the above would be:
psql -P format=unaligned -tc "\\du ${name} |grep '^ *${name}'"
Just an idea, for alternative approach.
Regards,
Michael
--
Michael Gliwinski
Henderson Group Information Services
9-11 Hightown Avenue, Newtownabby, BT36 4RT
Phone: 028 9034 3319
**********************************************************************************************
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee and access to the email by anyone else
is unauthorised.
If you are not the intended recipient, any disclosure, copying, distribution or
any action taken or omitted to be taken in reliance on it, is prohibited and
may be unlawful.
When addressed to our clients, any opinions or advice contained in this e-mail
are subject to the terms and conditions expressed in the governing client
engagement leter or contract.
If you have received this email in error please notify
[email protected]
John Henderson (Holdings) Ltd
Registered office: 9 Hightown Avenue, Mallusk, County Antrim, Northern Ireland,
BT36 4RT.
Registered in Northern Ireland
Registration Number NI010588
Vat No.: 814 6399 12
*********************************************************************************
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.