# Error creating jenkins user with the sudo cookbook

**URL:** <https://discourse.chef.io/t/error-creating-jenkins-user-with-the-sudo-cookbook/4670>\
**Category:** Chef Infra (archive)\
**Created:** [November 12, 2013, 10:13pm UTC](https://discourse.chef.io/t/error-creating-jenkins-user-with-the-sudo-cookbook/4670 "2013-11-12T22:13:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![philcryer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/philcryer/32/404_2.png) [@philcryer](https://discourse.chef.io/u/philcryer)\
**Post date:** [November 12, 2013, 10:13pm UTC](https://discourse.chef.io/t/error-creating-jenkins-user-with-the-sudo-cookbook/4670/1 "2013-11-12T22:13:40Z")

</div>

I’m using the Opscode sudo cookbook, and I’ve walked through the sudo  
example on their site ([http://docs.opscode.com/lwrp\_sudo.html](http://docs.opscode.com/lwrp_sudo.html)) but I  
get an error ‘validate\_fragment’ I’ve tried a few different things,  
but can’t find much else online on the topic; most refer to using sudo  
to install chef, run chef-client, etc. Thanks

via a GIST here: [https://gist.github.com/philcryer/7439401](https://gist.github.com/philcryer/7439401)

text:

[…CONFIG…]  
user “jenkins” do  
supports :manage\_home =\> true  
comment "The Jenkins user that handles all deploys"  
home "/home/jenkins"  
shell "/bin/bash"  
password "12341234"  
end  
node[‘authorization’][‘sudo’][‘include\_sudoers\_d’] = true  
include\_recipe "sudo"  
sudo “jenkins” do  
user “%jenkins"  
runas “app\_user"  
commands [”/etc/init.d/httpd restart”,“chown -R apache:apache /var/www”]  
host "ALL"  
nopasswd true  
end

[…LOGS…]  
[2013-11-12T15:45:34-06:00] DEBUG: package[sudo] is already installed

- nothing to do  
[2013-11-12T15:45:34-06:00] INFO: Processing directory[/etc/sudoers.d]  
action create (sudo::default line 25)  
[2013-11-12T15:45:34-06:00] INFO: Processing  
cookbook\_file[/etc/sudoers.d/README] action create (sudo::default line

1. 

[2013-11-12T15:45:34-06:00] INFO: Processing template[/etc/sudoers]  
action create (sudo::default line 39)  
[2013-11-12T15:45:34-06:00] DEBUG: Not fetching  
cookbooks/sudo/templates/default/sudoers.erb, as the cache is up to  
date.  
[2013-11-12T15:45:34-06:00] DEBUG: current checksum:  
6f178ce07803096acacaca23d243f2c2; manifest checksum:  
6f178ce07803096acacaca23d243f2c2)  
[2013-11-12T15:45:34-06:00] DEBUG: Current content’s checksum:  
261759ea279ca54103844c4a929fbcd3bd8b29f3e339ef334cbdea2405e7bd31  
[2013-11-12T15:45:34-06:00] DEBUG: Rendered content’s checksum:  
261759ea279ca54103844c4a929fbcd3bd8b29f3e339ef334cbdea2405e7bd31  
[2013-11-12T15:45:34-06:00] DEBUG: template[/etc/sudoers] content has  
not changed.  
[2013-11-12T15:45:34-06:00] INFO: Processing sudo[jenkins] action  
install (base::default line 135)  
[2013-11-12T15:45:34-06:00] DEBUG: Not fetching  
cookbooks/sudo/templates/default/sudoer.erb, as the cache is up to  
date.  
[2013-11-12T15:45:34-06:00] DEBUG: current checksum:  
f1a732fa44ee8eacc9ada77f75d580d3; manifest checksum:  
f1a732fa44ee8eacc9ada77f75d580d3)  
[2013-11-12T15:45:34-06:00] ERROR: Fragment validation failed:

[2013-11-12T15:45:34-06:00] ERROR: # This file is managed by Chef.

# Do NOT modify this file directly.

%jenkins ALL=(app\_user) NOPASSWD:/etc/init.d/httpd restart  
%jenkins ALL=(app\_user) NOPASSWD:chown -R apache:apache /var/www

[2013-11-12T15:45:34-06:00] FATAL: Template  
/tmp/sudoer20131112-12809-j5303y failed fragment validation!

# ================================================================================ Error executing action `install` on resource ‘sudo[jenkins]’

## SystemExit

exit

## Cookbook Trace:

/var/chef/cache/cookbooks/sudo/providers/default.rb:51:in `validate_fragment!' /var/chef/cache/cookbooks/sudo/providers/default.rb:96:in`render\_sudoer’  
/var/chef/cache/cookbooks/sudo/providers/default.rb:104:in `block in  
class\_from\_file’

## Resource Declaration:

# In /var/chef/cache/cookbooks/base/recipes/default.rb

135: sudo “jenkins” do  
136: user “%jenkins"  
137: runas “app\_user"  
138: commands [”/etc/init.d/httpd restart”,“chown -R apache:apache /opt/iaas”]  
139: host "ALL"  
140: nopasswd true  
141: end

## Compiled Resource:

# Declared in /var/chef/cache/cookbooks/base/recipes/default.rb:135:in

`from\_file’

sudo(“jenkins”) do  
action :install  
supports {:report=\>true, :exception=\>true}  
retries 0  
retry\_delay 2  
cookbook\_name "base"  
recipe\_name "default"  
user “%jenkins"  
runas “app\_user"  
commands [”/etc/init.d/httpd restart”, “chown -R apache:apache /opt/iaas”]  
host "ALL"  
nopasswd true  
end

[2013-11-12T15:45:34-06:00] DEBUG: Re-raising exception: SystemExit -  
sudo[jenkins] (base::default line 135) had an error: SystemExit: exit

---

<div class="post-metadata">

**Author:** ![Jorge\_Bianquetti](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jorge_bianquetti/32/432_2.png) [@Jorge\_Bianquetti](https://discourse.chef.io/u/Jorge_Bianquetti)\
**Post date:** [November 15, 2013, 9:25am UTC](https://discourse.chef.io/t/error-creating-jenkins-user-with-the-sudo-cookbook/4670/2 "2013-11-15T09:25:51Z")

</div>

It's simple, you can't name a system user "%jenkins".

2013/11/12 Phil Cryer [phil@philcryer.com](mailto:phil@philcryer.com):

> I'm using the Opscode sudo cookbook, and I've walked through the sudo  
> example on their site ([http://docs.opscode.com/lwrp\_sudo.html](http://docs.opscode.com/lwrp_sudo.html)) but I  
> get an error 'validate\_fragment' I've tried a few different things,  
> but can't find much else online on the topic; most refer to using sudo  
> to install chef, run chef-client, etc. Thanks
> 
> via a GIST here: [[CHEF] error creating jenkins user with the sudo cookbook · GitHub](https://gist.github.com/philcryer/7439401)
> 
> text:
> 
> [...CONFIG...]  
> user "jenkins" do  
> supports :manage\_home =\> true  
> comment "The Jenkins user that handles all deploys"  
> home "/home/jenkins"  
> shell "/bin/bash"  
> password "12341234"  
> end  
> node['authorization']['sudo']['include\_sudoers\_d'] = true  
> include\_recipe "sudo"  
> sudo "jenkins" do  
> user "%jenkins"  
> runas "app\_user"  
> commands ["/etc/init.d/httpd restart","chown -R apache:apache /var/www"]  
> host "ALL"  
> nopasswd true  
> end
> 
> [...LOGS...]  
> [2013-11-12T15:45:34-06:00] DEBUG: package[sudo] is already installed
> 
> - nothing to do  
> [2013-11-12T15:45:34-06:00] INFO: Processing directory[/etc/sudoers.d]  
> action create (sudo::default line 25)  
> [2013-11-12T15:45:34-06:00] INFO: Processing  
> cookbook\_file[/etc/sudoers.d/README] action create (sudo::default line
> 
> 1. 
> 
> [2013-11-12T15:45:34-06:00] INFO: Processing template[/etc/sudoers]  
> action create (sudo::default line 39)  
> [2013-11-12T15:45:34-06:00] DEBUG: Not fetching  
> cookbooks/sudo/templates/default/sudoers.erb, as the cache is up to  
> date.  
> [2013-11-12T15:45:34-06:00] DEBUG: current checksum:  
> 6f178ce07803096acacaca23d243f2c2; manifest checksum:  
> 6f178ce07803096acacaca23d243f2c2)  
> [2013-11-12T15:45:34-06:00] DEBUG: Current content's checksum:  
> 261759ea279ca54103844c4a929fbcd3bd8b29f3e339ef334cbdea2405e7bd31  
> [2013-11-12T15:45:34-06:00] DEBUG: Rendered content's checksum:  
> 261759ea279ca54103844c4a929fbcd3bd8b29f3e339ef334cbdea2405e7bd31  
> [2013-11-12T15:45:34-06:00] DEBUG: template[/etc/sudoers] content has  
> not changed.  
> [2013-11-12T15:45:34-06:00] INFO: Processing sudo[jenkins] action  
> install (base::default line 135)  
> [2013-11-12T15:45:34-06:00] DEBUG: Not fetching  
> cookbooks/sudo/templates/default/sudoer.erb, as the cache is up to  
> date.  
> [2013-11-12T15:45:34-06:00] DEBUG: current checksum:  
> f1a732fa44ee8eacc9ada77f75d580d3; manifest checksum:  
> f1a732fa44ee8eacc9ada77f75d580d3)  
> [2013-11-12T15:45:34-06:00] ERROR: Fragment validation failed:
> 
> [2013-11-12T15:45:34-06:00] ERROR: # This file is managed by Chef.
> 
> # Do NOT modify this file directly.
> 
> %jenkins ALL=(app\_user) NOPASSWD:/etc/init.d/httpd restart  
> %jenkins ALL=(app\_user) NOPASSWD:chown -R apache:apache /var/www
> 
> [2013-11-12T15:45:34-06:00] FATAL: Template  
> /tmp/sudoer20131112-12809-j5303y failed fragment validation!
> 
> # ================================================================================ Error executing action `install` on resource 'sudo[jenkins]'
> 
> ## SystemExit
> 
> exit
> 
> ## Cookbook Trace:
> 
> /var/chef/cache/cookbooks/sudo/providers/default.rb:51:in `validate_fragment!' /var/chef/cache/cookbooks/sudo/providers/default.rb:96:in `render\_sudoer'  
> /var/chef/cache/cookbooks/sudo/providers/default.rb:104:in `block in  
> class\_from\_file'
> 
> ## Resource Declaration:
> 
> # In /var/chef/cache/cookbooks/base/recipes/default.rb
> 
> 135: sudo "jenkins" do  
> 136: user "%jenkins"  
> 137: runas "app\_user"  
> 138: commands ["/etc/init.d/httpd restart","chown -R apache:apache /opt/iaas"]  
> 139: host "ALL"  
> 140: nopasswd true  
> 141: end
> 
> ## Compiled Resource:
> 
> # Declared in /var/chef/cache/cookbooks/base/recipes/default.rb:135:in
> 
> `from\_file'
> 
> sudo("jenkins") do  
> action :install  
> supports {:report=\>true, :exception=\>true}  
> retries 0  
> retry\_delay 2  
> cookbook\_name "base"  
> recipe\_name "default"  
> user "%jenkins"  
> runas "app\_user"  
> commands ["/etc/init.d/httpd restart", "chown -R apache:apache /opt/iaas"]  
> host "ALL"  
> nopasswd true  
> end
> 
> [2013-11-12T15:45:34-06:00] DEBUG: Re-raising exception: SystemExit -  
> sudo[jenkins] (base::default line 135) had an error: SystemExit: exit

---

<div class="post-metadata">

**Author:** ![philcryer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/philcryer/32/404_2.png) [@philcryer](https://discourse.chef.io/u/philcryer)\
**Post date:** [November 15, 2013, 2:45pm UTC](https://discourse.chef.io/t/error-creating-jenkins-user-with-the-sudo-cookbook/4670/3 "2013-11-15T14:45:47Z")

</div>

Thanks!

On Fri, Nov 15, 2013 at 3:25 AM, Jorge Bianquetti [jbianquetti@gmail.com](mailto:jbianquetti@gmail.com)wrote:

> It's simple, you can't name a system user "%jenkins".
> 
> 2013/11/12 Phil Cryer [phil@philcryer.com](mailto:phil@philcryer.com):
> 
> > I'm using the Opscode sudo cookbook, and I've walked through the sudo  
> > example on their site ([http://docs.opscode.com/lwrp\_sudo.html](http://docs.opscode.com/lwrp_sudo.html)) but I  
> > get an error 'validate\_fragment' I've tried a few different things,  
> > but can't find much else online on the topic; most refer to using sudo  
> > to install chef, run chef-client, etc. Thanks
> > 
> > via a GIST here: [[CHEF] error creating jenkins user with the sudo cookbook · GitHub](https://gist.github.com/philcryer/7439401)
> > 
> > text:
> > 
> > [...CONFIG...]  
> > user "jenkins" do  
> > supports :manage\_home =\> true  
> > comment "The Jenkins user that handles all deploys"  
> > home "/home/jenkins"  
> > shell "/bin/bash"  
> > password "12341234"  
> > end  
> > node['authorization']['sudo']['include\_sudoers\_d'] = true  
> > include\_recipe "sudo"  
> > sudo "jenkins" do  
> > user "%jenkins"  
> > runas "app\_user"  
> > commands ["/etc/init.d/httpd restart","chown -R apache:apache  
> > /var/www"]  
> > host "ALL"  
> > nopasswd true  
> > end
> > 
> > [...LOGS...]  
> > [2013-11-12T15:45:34-06:00] DEBUG: package[sudo] is already installed
> > 
> > - nothing to do  
> > [2013-11-12T15:45:34-06:00] INFO: Processing directory[/etc/sudoers.d]  
> > action create (sudo::default line 25)  
> > [2013-11-12T15:45:34-06:00] INFO: Processing  
> > cookbook\_file[/etc/sudoers.d/README] action create (sudo::default line
> > 
> > 1. 
> > 
> > [2013-11-12T15:45:34-06:00] INFO: Processing template[/etc/sudoers]  
> > action create (sudo::default line 39)  
> > [2013-11-12T15:45:34-06:00] DEBUG: Not fetching  
> > cookbooks/sudo/templates/default/sudoers.erb, as the cache is up to  
> > date.  
> > [2013-11-12T15:45:34-06:00] DEBUG: current checksum:  
> > 6f178ce07803096acacaca23d243f2c2; manifest checksum:  
> > 6f178ce07803096acacaca23d243f2c2)  
> > [2013-11-12T15:45:34-06:00] DEBUG: Current content's checksum:  
> > 261759ea279ca54103844c4a929fbcd3bd8b29f3e339ef334cbdea2405e7bd31  
> > [2013-11-12T15:45:34-06:00] DEBUG: Rendered content's checksum:  
> > 261759ea279ca54103844c4a929fbcd3bd8b29f3e339ef334cbdea2405e7bd31  
> > [2013-11-12T15:45:34-06:00] DEBUG: template[/etc/sudoers] content has  
> > not changed.  
> > [2013-11-12T15:45:34-06:00] INFO: Processing sudo[jenkins] action  
> > install (base::default line 135)  
> > [2013-11-12T15:45:34-06:00] DEBUG: Not fetching  
> > cookbooks/sudo/templates/default/sudoer.erb, as the cache is up to  
> > date.  
> > [2013-11-12T15:45:34-06:00] DEBUG: current checksum:  
> > f1a732fa44ee8eacc9ada77f75d580d3; manifest checksum:  
> > f1a732fa44ee8eacc9ada77f75d580d3)  
> > [2013-11-12T15:45:34-06:00] ERROR: Fragment validation failed:
> > 
> > [2013-11-12T15:45:34-06:00] ERROR: # This file is managed by Chef.
> > 
> > # Do NOT modify this file directly.
> > 
> > %jenkins ALL=(app\_user) NOPASSWD:/etc/init.d/httpd restart  
> > %jenkins ALL=(app\_user) NOPASSWD:chown -R apache:apache /var/www
> > 
> > [2013-11-12T15:45:34-06:00] FATAL: Template  
> > /tmp/sudoer20131112-12809-j5303y failed fragment validation!
> 
> ================================================================================
> 
> > Error executing action `install` on resource 'sudo[jenkins]'
> 
> ================================================================================
> 
> > ## SystemExit
> > 
> > exit
> > 
> > ## Cookbook Trace:
> > 
> > /var/chef/cache/cookbooks/sudo/providers/default.rb:51:in  
> > `validate_fragment!' /var/chef/cache/cookbooks/sudo/providers/default.rb:96:in `render\_sudoer'  
> > /var/chef/cache/cookbooks/sudo/providers/default.rb:104:in `block in  
> > class\_from\_file'
> > 
> > ## Resource Declaration:
> > 
> > # In /var/chef/cache/cookbooks/base/recipes/default.rb
> > 
> > 135: sudo "jenkins" do  
> > 136: user "%jenkins"  
> > 137: runas "app\_user"  
> > 138: commands ["/etc/init.d/httpd restart","chown -R apache:apache  
> > /opt/iaas"]  
> > 139: host "ALL"  
> > 140: nopasswd true  
> > 141: end
> > 
> > ## Compiled Resource:
> > 
> > # Declared in /var/chef/cache/cookbooks/base/recipes/default.rb:135:in
> > 
> > `from\_file'
> > 
> > sudo("jenkins") do  
> > action :install  
> > supports {:report=\>true, :exception=\>true}  
> > retries 0  
> > retry\_delay 2  
> > cookbook\_name "base"  
> > recipe\_name "default"  
> > user "%jenkins"  
> > runas "app\_user"  
> > commands ["/etc/init.d/httpd restart", "chown -R apache:apache  
> > /opt/iaas"]  
> > host "ALL"  
> > nopasswd true  
> > end
> > 
> > [2013-11-12T15:45:34-06:00] DEBUG: Re-raising exception: SystemExit -  
> > sudo[jenkins] (base::default line 135) had an error: SystemExit: exit

--  
[http://philcryer.com/](http://philcryer.com/)
