Problem by calling puppet script on LINUX

30 views
Skip to first unread message

Wei Chen

unread,
Oct 29, 2015, 9:41:47 AM10/29/15
to Jenkins Users
Hi,

I created a job in Jenkins which will start the puppet agent with command:
puppet agent -t

This command works fine under LINUX.

But as I build the job in Jenkins I got following errors:
...
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/TestPuppet/workspace
[workspace] $ /bin/sh -xe /tmp/hudson50649338283499454.sh
+ puppet agent -t
 [1;35merr: /File[/home/jenkins/.puppet]/ensure: change from absent to directory failed: Cannot create /home/jenkins/.puppet; parent directory /home/jenkins does not exist [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/ssl]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/ssl]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/ssl/private]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/ssl/private]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/ssl/certificate_requests]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/ssl/certificate_requests]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/log]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/log]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/facts]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/facts]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/clientbucket]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/clientbucket]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/state]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/state]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/state/graphs]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/state/graphs]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/lib]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/lib]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/client_data]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/client_data]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/ssl/private_keys]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/ssl/private_keys]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/client_yaml]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/client_yaml]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/var/run]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/var/run]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/ssl/public_keys]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/ssl/public_keys]: Skipping because of failed dependencies [0m
 [0;36mnotice: /File[/home/jenkins/.puppet/ssl/certs]: Dependency File[/home/jenkins/.puppet] has failures: true [0m
 [0;33mwarning: /File[/home/jenkins/.puppet/ssl/certs]: Skipping because of failed dependencies [0m
Could not prepare for execution: Got 1 failure(s) while initializing: change from absent to directory failed: Cannot create /home/jenkins/.puppet; parent directory /home/jenkins does not exist
Build step 'Execute shell' marked build as failure
Finished: FAILURE




Can someone help?


Regards

Dirk Heinrichs

unread,
Oct 29, 2015, 10:03:10 AM10/29/15
to jenkins...@googlegroups.com
Am 29.10.2015 um 14:41 schrieb Wei Chen:
[workspace] $ /bin/sh -xe /tmp/hudson50649338283499454.sh
+ puppet agent -t
 [1;35merr: /File[/home/jenkins/.puppet]/ensure: change from absent to directory failed: Cannot create /home/jenkins/.puppet; parent directory /home/jenkins does not exist [0m

If the puppet agent doesn't run as root, it creates a data folder under $HOME/.puppet. If $HOME doesn't exist, .puppet can't be created.

However, it doesn't make much sense to run the puppet agent as non-root user (it won't be able to install any package, for example), so what you would likely want to do is setup sudo so that the user "jenkins" can execute "puppet agent -t" (and only this) as root w/o providing a password, then call "sudo puppet agent -t".

See "man sudoers" for details.

HTH...

    Dirk
--

Dirk Heinrichs, Senior Systems Engineer, Engineering Solutions
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Tel: +49 2226 1596666 (Ansage) 1149
Email: d...@recommind.com
Skype: dirk.heinrichs.recommind
www.recommind.com

R. Tyler Croy

unread,
Oct 29, 2015, 10:05:17 AM10/29/15
to jenkins...@googlegroups.com
(replies inline)

On Thu, 29 Oct 2015, Wei Chen wrote:

> Hi,
>
> I created a job in Jenkins which will start the puppet agent with command:
> puppet agent -t
>
>
> Could not prepare for execution: Got 1 failure(s) while initializing: change from absent to directory failed: Cannot create /home/jenkins/.puppet; parent directory /home/jenkins does not exist
> Build step 'Execute shell' marked build as failure
> Finished: FAILURE


This looks to me to definitely be a Puppet code problem, since the following
code will not recursively create a directory:

file { '/foo/bar': ensure => directory; }



- R. Tyler Croy

------------------------------------------------------
Code: <https://github.com/rtyler>
Chatter: <https://twitter.com/agentdero>

% gpg --keyserver keys.gnupg.net --recv-key 3F51E16F
------------------------------------------------------
signature.asc

Dirk Heinrichs

unread,
Oct 29, 2015, 10:10:12 AM10/29/15
to jenkins...@googlegroups.com
Am 29.10.2015 um 15:03 schrieb R. Tyler Croy:

This looks to me to definitely be a Puppet code problem,

Nope. It's a problem of running "puppet agent" as non-root user w/o existing $HOME for that user.

Bye...

R. Tyler Croy

unread,
Oct 29, 2015, 10:23:54 AM10/29/15
to jenkins...@googlegroups.com
(replies inline)

On Thu, 29 Oct 2015, Dirk Heinrichs wrote:

> Am 29.10.2015 um 15:03 schrieb R. Tyler Croy:
>
> > This looks to me to definitely be a Puppet code problem,
>
> Nope. It's a problem of running "puppet agent" as non-root user w/o
> existing $HOME for that user.


Yeah, I saw your message after I sent mine. Interesting! I've never seen that
error in my own puppet agents before, must be lucky I guess :)
signature.asc

Felipe Grucci

unread,
Mar 8, 2018, 2:20:38 PM3/8/18
to Jenkins Users
I have the same error, but when I run the "puppet agent -t" command with a Jenkins job in a Windows environment

In Jenkins I have a Job with Powershell scripts that calls the PUPPET AGENT -T

Thanks in Advanced
Reply all
Reply to author
Forward
0 new messages