FAQ
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:

--
#!/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
if [ $? -ne 0 ]
then
echo "Puppet syntax error in $file" 1>&2
exit 1
fi
done
--

Here is my nodes.pp file that is being edited:

--
node 'testrhel.gene.com' { include simtestfile }
--

Now with this node.pp file I am able to update the testrhel server with the
simtestfile just fine and the puppet parser validate command does not
complain if I run it manually:

--
[root@ssfpuppetd01 hooks]# puppet parser validate
/etc/puppet/manifests/nodes.pp
[root@ssfpuppetd01 hooks]#
--

However, now when I try to svn ci this file I get an error and it looks
like it is because the above command returns a 1 for some reason:

--
..snip..
Sending nodes.pp
Transmitting file data .svn: Commit failed (details follow):
svn: Commit blocked by pre-commit hook (exit code 1) with output:
+ REPOS=/var/svn/repos/puppet
+ TXN=30-28
++ mktemp
+ tmpfile=/tmp/tmp.EmWYD21813
+ export
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
++ svnlook changed -t 30-28 /var/svn/repos/puppet
++ awk '/^[^D].*\.pp$/ {print $2}'
+ for file in '$(svnlook changed -t "$TXN" "$REPOS" | awk
'\''/^[^D].*\.pp$/ {print $2}'\'')'
+ svnlook cat -t 30-28 /var/svn/repos/puppet manifests/nodes.pp
Sending nodes.pp
Transmitting file data .svn: Commit failed (details follow):
svn: Commit blocked by pre-commit hook (exit code 1) with output:
+ REPOS=/var/svn/repos/puppet
+ TXN=30-28
++ mktemp
+ tmpfile=/tmp/tmp.EmWYD21813
+ export
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
++ svnlook changed -t 30-28 /var/svn/repos/puppet
++ awk '/^[^D].*\.pp$/ {print $2}'
+ for file in '$(svnlook changed -t "$TXN" "$REPOS" | awk
'\''/^[^D].*\.pp$/ {print $2}'\'')'
+ svnlook cat -t 30-28 /var/svn/repos/puppet manifests/nodes.pp
*+ puppet parser validate /tmp/tmp.EmWYD21813*
*+ '[' 1 -ne 0 ']'*
+ echo 'Puppet syntax error in manifests/nodes.pp'
Puppet syntax error in manifests/nodes.pp
+ exit 1
--

However, if I run that command manually it does not return any errors:
--
[root@ssfpuppetd01 hooks]# puppet parser validate /tmp/tmp.EmWYD21813
[root@ssfpuppetd01 hooks]# cat /tmp/tmp.EmWYD21813
node 'testrhel.gene.com' {
include simtestfile
}
[root@ssfpuppetd01 hooks]#
--

Any help would be greatly appreciated.

Thanks,
-J

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/W2HkSI7z5FcJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Matthew Burgess at Dec 14, 2012 at 10:49 am

    On Fri, Dec 14, 2012 at 2:00 AM, Jagga Soorma 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.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Jagga Soorma at Dec 14, 2012 at 5:42 pm
    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

    On Friday, December 14, 2012 2:49:11 AM UTC-8, Matthew Burgess wrote:
    On Fri, Dec 14, 2012 at 2:00 AM, Jagga Soorma 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.
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/YpOlchBjNg0J.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Matthew Burgess at Dec 15, 2012 at 10:04 pm

    On Fri, Dec 14, 2012 at 5:42 PM, Jagga Soorma 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.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Jakov Sosic at Dec 16, 2012 at 12:06 am

    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

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedDec 14, '12 at 5:36a
activeDec 16, '12 at 12:06a
posts5
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2021 Grokbase