Re: [Puppet Users] New Puppet User: Issues with pre-commit script

293 views
Skip to first unread message

Matthew Burgess

unread,
Dec 14, 2012, 5:49:11 AM12/14/12
to puppet...@googlegroups.com
On Fri, Dec 14, 2012 at 2:00 AM, Jagga Soorma <jag...@gmail.com> wrote:

> #!/bin/bash
>
> REPOS="$1"
> TXN="$2"
> tmpfile=$(mktemp)
> export
> PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
>
> for file in $(svnlook changed -t "$TXN" "$REPOS" | awk '/^[^D].*\.pp$/
> {print $2}')
> do
> svnlook cat -t $TXN $REPOS $file > $tmpfile
> puppet parser validate $tmpfile &>/dev/null

That '&' looks a little odd there. I think what you probably want is

puppet parser validate $tmpfile >/dev/null 2>&1

However, while debugging your issue, I'd recommend capturing the output:

puppet parser validate $tmpfile >/tmp/puppet-validation.log 2>&1

That should at least give you a hint as to what's going on...hopefully!

Regards,

Matt.

Jagga Soorma

unread,
Dec 14, 2012, 12:42:13 PM12/14/12
to puppet...@googlegroups.com
Thanks for your reply Matthew.  I changed that line to the following:

        /usr/bin/puppet parser validate  $tmpfile >> /tmp/puppet-val.log 2>&1

Here is what the log is capturing (problem with the environment?):

--
simran@shinda:/var/tmp/puppet/puppet/manifests$ svn ci -m 'testing' nodes.pp
..snip..
Sending        nodes.pp
Transmitting file data .svn: Commit failed (details follow):
svn: Commit blocked by pre-commit hook (exit code 1) with output:
Puppet syntax error in manifests/nodes.pp

[root@ssfpuppetd01 hooks]# cat /tmp/puppet-val.log
Error: Could not intialize global default settings: couldn't find HOME environment -- expanding `~/.puppet'
--

Regards,
-J

Matthew Burgess

unread,
Dec 15, 2012, 5:04:01 PM12/15/12
to puppet...@googlegroups.com
On Fri, Dec 14, 2012 at 5:42 PM, Jagga Soorma <jag...@gmail.com> wrote:
> Thanks for your reply Matthew. I changed that line to the following:
>
> /usr/bin/puppet parser validate $tmpfile >> /tmp/puppet-val.log
> 2>&1
>
> Here is what the log is capturing (problem with the environment?):
>
> --
> simran@shinda:/var/tmp/puppet/puppet/manifests$ svn ci -m 'testing' nodes.pp
>
> ..snip..
> Sending nodes.pp
> Transmitting file data .svn: Commit failed (details follow):
> svn: Commit blocked by pre-commit hook (exit code 1) with output:
> Puppet syntax error in manifests/nodes.pp
>
> [root@ssfpuppetd01 hooks]# cat /tmp/puppet-val.log
> Error: Could not intialize global default settings: couldn't find HOME
> environment -- expanding `~/.puppet'

OK. Subversion calls hook scripts with an empty environment for
security reasons. See
http://svnbook.red-bean.com/en/1.7/svn.reposadmin.create.html#svn.reposadmin.create.hooks.

So, your hook script is going to have to set HOME itself.

Regards,

Matt.

Jakov Sosic

unread,
Dec 15, 2012, 7:06:23 PM12/15/12
to puppet...@googlegroups.com
On 12/14/2012 03:00 AM, Jagga Soorma wrote:
> Hi Guys,
>
> I am new to puppet so please let me know if this is not the correct
> place for asking this question. I am setting up a new puppet
> environment running the latest 3.x version. I have the puppet master
> and client setup correctly and tested with deploying a simple file to
> the client. Now, I am working on adding all the configs to SVN since I
> will have all my users checkout the nodes.pp file and place their node
> entries in this file via SVN. I would like to do some check on this
> file before it is checked in to make sure there are no syntax errors. I
> am using the following pre-commit scirpt that I came across online:

Take a look at my precommit script and modify it to suit SVN... You will
need puppet & rubygem-puppet-lint to get it to work:

http://kosjenka.srce.hr/~jsosic/puppet/check_puppet.rb




--
Jakov Sosic
www.srce.unizg.hr
Reply all
Reply to author
Forward
0 new messages