qua*_*nta 5 shell puppet command execution
我想要~/.bashrc
将是source
每当改变其内容。我用这样的东西创建了一个 bashrc 类:
file { "/root/.bashrc":
ensure => present,
owner => root,
group => root,
mode => 0644,
source => "puppet:///bashrc/root/.bashrc"
}
exec { "root_bashrc":
command => "source /root/.bashrc",
subscribe => File["/root/.bashrc"],
}
Run Code Online (Sandbox Code Playgroud)
但如您所知,它source
是一个 shell 内置命令,因此在运行代理时出现以下错误:
# puppet agent --no-daemonize --verbose
notice: Starting Puppet client version 2.7.1
info: Caching catalog for svr051-4170
info: Applying configuration version '1311563901'
err: /Stage[main]/Bashrc/Exec[root_bashrc]/returns: change from notrun to 0 failed: Could not find command 'source'
notice: Finished catalog run in 2.28 seconds
notice: Caught INT; calling stop
Run Code Online (Sandbox Code Playgroud)
有什么解决方法可以做到这一点吗?
在 Puppet中重新source
创建 new是没有意义的.bashrc
,因为它将在子 shell 中运行并且更改不会传播到您当前的 shell(我假设,这就是您正在尝试做的)。你不能做(我认为)你想做的事。
小智 5
您还可以经常在命令前加上true &&
或 使用provider => shell
。
这应该是:
file { "/root/.bashrc":
ensure => present,
owner => root,
group => root,
mode => 0644,
source => "puppet:///bashrc/root/.bashrc" }
exec { "root_bashrc":
command => "source /root/.bashrc",
provider => shell,
subscribe => File["/root/.bashrc"],
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13471 次 |
最近记录: |