I have a CentOS base box in Vagrant that I'm standing up with a puppet manifest. Here's what's in the manifest so far:
class base {
exec { "sudocmd":
path => ["/usr/bin/","/usr/sbin/","/bin"],
command => "sudo yum update -y",
}
package { "man":
ensure => present,
}
package { "bind":
ensure => present,
}
package { "bind-utils":
ensure => present,
}
}
include base
But when I say vagrant up
, I get an error that sudocmd yum update
exited with a 1. I've looked on the web, but I haven't found a solution for this yet. Any help?
========EDIT========= I read the answers and I agree - thanks guys. I'm just using this on a dev box to mess around and I needed it to be up to date before I started doing work on it.
With puppet, you shouldn't need to use sudo
, just run the yum
command directly. Normally commands will run as root by default, but you can specify what user.
exec { "sudocmd":
path => ["/usr/bin/","/usr/sbin/","/bin"],
command => "yum update -y",
user => root,
}
However, I strongly recommend that you do not use any kind of non-conditional exec
with puppet. That will run every time puppet runs. As Forrest already said , it's not what puppet is designed for. I wouldn't use puppet for a yum update
, and my exec
s always have creates
, onlyif
, refreshonly
or unless
to ensure they only run when needed.
So Puppet isn't really meant to perform tasks like a yum update. It's a configuration management tool, not something that completely replaces this sort of task. In addition you run into a lot of issues with this. What if Puppet is daemonized? Will this negatively impact our production environment? What happens if a user accidentally runs Puppet and it updates a package that breaks our scripts (JDK, MySQL, PHP, etc.). As far as I'm aware there is no solution to this because it's not really considered a problem. Scott Pack over on Serverfault provided a very descriptive answer to a similar question.
updating "path" attribute helps me. sudo and apt-get commands are available in /usr/bin/ path
exec { 'autoclean':
command => 'apt-get autoclean',
path => '/usr/local/bin/:/bin/:/usr/bin/',
cwd => '/home',
}
my puppet version: 5.5.1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.