【发布时间】:2021-08-30 11:10:40
【问题描述】:
exec {'alias':
command => 'source /etc/profile',
path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ],
provider => shell,
}
/etc/profile
alias extend_shutdown_15='bash extend_shutdown.sh 15'
因此,在执行资源中使用“source /etc/profile”命令时,我想在任何配置更改后更新“/etc/profile”,但出现以下错误:
Error: Could not find command 'source'
Error: /Stage[main]/Main/Node[default]/Exec[alias]/returns: change from 'notrun' to ['0'] failed: Could not find command 'source' (corrective)
【问题讨论】:
-
source /etc/profile即使成功也不会造成任何永久性更改。为什么要这样做? -
我想为命令创建别名,所以我打算添加到 /etc/profile 中以使其成为全局,因此将这些配置更改影响到我们的系统需要运行“reboot”或“source /etc /轮廓” ?我正在尝试这些 puppet exec,但由于源命令而出错
-
好的,那么
exec资源中的隔离source /etc/profile将无法为您实现此目的。您可能应该考虑以其他方式执行此操作。 -
此外,将别名放入
/etc/profile并不会使它们成为全局变量。根据环境和参数,在 shell 初始化期间并不总是读取该文件。此外,别名不会传递给子进程,默认情况下,它们不会被非交互式 shell 扩展。此外,它们不会与使用替代 shell 的人共享。如果您想向系统添加新命令,请考虑编写可执行的 shell 脚本并将它们放在默认 PATH 中的某个位置。