gpt4 book ai didi

linux - 当用户主目录安装在 NFS 卷上时 Ansible 不起作用

转载 作者:太空狗 更新时间:2023-10-29 11:49:54 24 4
gpt4 key购买 nike

情况是这样的。我有很多主机,我想通过 Ansible 维护它们。登录名/用户等主机的基线配置由企业 IT 霸主控制,因此我只能更改与应用程序相关的内容,而不是一般主机设置。一些与应用程序相关的任务需要以“root”或其他特权用户身份运行。

我在所有主机上都有无密码的 sudo 访问权限,但是所有用户主目录都位于 NFS 挂载卷上。根据我对 ansible 工作原理的理解,它首先以普通用户身份登录目标主机并将一些文件放入 $HOME/.ansible 目录,然后使用 sudo 切换到 root 用户并尝试运行该目录中的内容。

但是问题来了。正如我上面提到的,主目录位于 NFS 卷上,因此在目标机器上的 ansible 进程成为根目录后,由于 NFS 限制,它无法再访问 $HOME/.ansible 目录。有没有办法告诉 ansible 将这些工作文件放在某些非 NFS 卷上的主目录之外。

最佳答案

Ansible 2.1 中引入的ansible.cfg 配置文件有两个参数,可以指定目标机和控制机上临时目录的位置:

  • remote_tmp

    Ansible works by transferring modules to your remote machines, running them, and then cleaning up after itself. In some cases, you may not wish to use the default location and would like to change the path. You can do so by altering this setting:

    remote_tmp = ~/.ansible/tmp
  • local_tmp

    When Ansible gets ready to send a module to a remote machine it usually has to add a few things to the module: Some boilerplate code, the module’s parameters, and a few constants from the config file. This combination of things gets stored in a temporary file until ansible exits and cleans up after itself. The default location is a subdirectory of the user’s home directory. If you’d like to change that, you can do so by altering this setting:

    local_tmp = $HOME/.ansible/tmp

关于linux - 当用户主目录安装在 NFS 卷上时 Ansible 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42428204/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com