Ansible剧本 - 许可被拒绝

时间:2018-04-08 16:31:56

标签: ansible file-permissions

我正在尝试从Ansible 2.3.1.0运行一本剧本。 我的远程机器是RHEL7,Python安装在/ usr / bin / python中。

我的剧本看起来像这样:

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 26, Android SDK Build-Tools 26.0.2].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

我收到的错误:

#include <iostream>
#include <string>
#include <cctype>

int main()
{
    if(std::isdigit(static_cast<unsigned char>(std::cin.peek())))
    {
        //the input is a number
        int num;
        std::cin >> num;
        //do stuff with num
    }
    else
    {
        //input is something else
        std::string str;
        std::cin >> str;
        //do stuff with str;
    }
}

由Ansible创建的文件“setup.py”具有权限“700 myuser myuser”,我想这是一个问题?

如何让Ansible允许root运行脚本? 我甚至不确定这是不是问题?

1 个答案:

答案 0 :(得分:2)

我设法找出问题所在。应该永远不会在主文件夹&#34; / home / myuser&#34;中创建setup.py文件。 root无权访问。

我尝试设置环境变量TMPDIR和变量&#34; remote_tmp&#34;在ansible.cfg中,如下所示。

ansible.cfg:

remote_tmp = /tmp/ansible-$USER

问题是,我错过了包含&#34; [默认]&#34; &#34;节标题&#34;在指定&#34; remote_tmp&#34;之前参数。下面的ansible.cfg文件按预期工作。

ansible.cfg:

[defaults]
remote_tmp = /tmp/ansible-$USER