When git feeds the file to puppet parser on your git repo server, it is
doing so via a temporary file (evidenced by remote: Error: Could not parse
for environment production: No file(s) found for import of
''fix.pp'' at
/tmp/tmp.hujjYZKPpC/manifests/nodes.pp:9 ). Because it is a temporary file
it does not have the rest of the git tree available, and so the import
''fix.pp'' line cannot succeed (on your git repo server.
Obviously the file
works perfectly fine with a working tree to use).
From http://projects.puppetlabs.com/projects/1/wiki/puppet_version_control
# NOTE: There is an outstanding bug against `puppet parser` which causes #
the --ignoreimport option to turn the syntax check into a no-op. Until #
the bug is resolved, the syntax check hook should not include the #
--ignoreimport option and will only work correctly on manifests which # do
not contain "import" lines. # See
http://projects.puppetlabs.com/issues/9670
You can try to work around this on your server-side hook by changing
git cat-file blob $new_sha1 > $tmp
to
git cat-file blob $new_sha1 | grep -v ''^\s*import'' > $tmp
disclaimer - I''ve not tested this, I am not a doctor, etc.
Jeff
On Tue, Dec 10, 2013 at 9:31 AM, Andreas Dvorak
<andreas.dvorak@gmail.com>wrote:
> Dear all,
>
> In git I have a pre-receive script to checkt the puppet files. My git push
> comes with an error but if I run the same manually I get no error.
> Can anybody please help me?
>
> error message
> remote: Checking manifests/nodes.pp for syntax errors and styleguide
> compliance...
> remote: ''puppet parser validate'' failed on
manifests/nodes.pp - push
> deniend. Run tests locally and confirm they pass before pushing.
> remote: Error: Could not parse for environment production: No file(s)
> found for import of ''fix.pp'' at
/tmp/tmp.hujjYZKPpC/manifests/nodes.pp:9
> remote: Error: Try ''puppet help parser validate'' for
usage
>
> pre-receive script
> for puppetmodule in `git diff-tree --no-commit-id --name-only -r $newrev`;
> do
> echo -e "\e[0;36m" "Checking $puppetmodule for
syntax errors and
> styleguide compliance..." "\e[0m"
> tmpdir=`mktemp -d`
> tmpmodule="$tmpdir/$puppetmodule"
> tmperror="$tmpdir/errors.txt"
> mkdir -p $tmpmodule
> rmdir $tmpmodule
> git show $newrev:$puppetmodule > $tmpmodule
> case $puppetmodule in
> *.pp )
> puppet parser validate $tmpmodule 2&> $tmperror
> rc=$?
> if [[ $rc != 0 ]]; then
> echo -e
"\e[0;31m''puppet parser
> validate'' failed on $puppetmodule - push deniend. Run tests
locally and
> confirm they pass before pushing. \e[0m"
> cat $tmperror
> rm -rf $tmpdir
> exit $rc
> fi
> .....
>
> this works without error in my local git and on the central git
> puppet parser validate nodes.pp
>
> cat nodes.pp
> node base {
> include profiles::base
> }
>
> node ''sv2629.muc.baag'' inherits base {
> }
>
> import ''fix.pp''
> import ''puppet_master.pp''
> #import ''sunray.pp''
>
> And it does not matter what I change in the file.
>
> Best regards
> Andreas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/puppet-users/e2d78e37-0746-4fed-b590-fd9246d4d605%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/CAHahqg34z5Tue%3D8_VR6BkiyOWfTqm7tkKX%3DKAfyXz8-GRGOekA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.