gpt4 book ai didi

ansible - 关于ansible,尝试执行脚本时权限被拒绝

转载 作者:行者123 更新时间:2023-12-04 23:20:28 27 4
gpt4 key购买 nike

我是 ansible 的新手,所以在尝试运行自己的剧本时出现错误。

我的剧本因此操作而失败:

# run check-feed-adapter-folders script. the script tries to create some folders on HDFS.
- command: "{{check_feed_adapter_folders_outputpath}}/check.sh"

这是 ansible-playbook 命令的输出:
TASK: [command {{check_feed_adapter_folders_outputpath}}/check-feed.sh] *******
<127.0.0.1> REMOTE_MODULE command /var/app/check-feed-adapter-folders/check-feed.sh
<127.0.0.1> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1423231416.19-167270274703096 && echo $HOME/.ansible/tmp/ansible-tmp-1423231416.19-167270274703096']
<127.0.0.1> PUT /tmp/tmpvB4uTB TO /root/.ansible/tmp/ansible-tmp-1423231416.19-167270274703096/command
<127.0.0.1> EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1423231416.19-167270274703096/command; rm -rf /root/.ansible/tmp/ansible-tmp-1423231416.19-167270274703096/ >/dev/null 2>&1']
failed: [127.0.0.1] => {"cmd": "/var/app/check-feed-adapter-folders/check-feed.sh", "failed": true, "rc": 13}
msg: [Errno 13] Permission denied

FATAL: all hosts have already failed -- aborting

这很奇怪,因为如果我尝试手动运行脚本,它会完美运行
[root@dub-vcd-vms171 core2door.ansible]# sh /var/app/check-feed-adapter-folders/check-feed.sh     [INFO][CheckTopologyFolder][2015-02-06 14:05:32] CheckFeedFolder:41 - Started main method CheckTopologyFolder. param1: /var/app/feed-adapter/feed-adapter-SIP-Pub.properties
[INFO][CheckTopologyFolder][2015-02-06 14:05:32] CheckFeedFolder:47 - Trying to create the folder on HDFS
[INFO][CheckTopologyFolder][2015-02-06 14:05:32] MyHadoopUtils:28 - Started using hdfs://dub-vcd-vms169.global.tektronix.net:8020/
[WARN][CheckTopologyFolder][2015-02-06 14:05:33] NativeCodeLoader:62 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable

如果我尝试通过 shell 更改命令,同样的错误:
failed: [127.0.0.1] => {"changed": true, "cmd": "/var/app/check-feed-adapter-folders/check-feed.sh", "delta": "0:00:00.004738", "end": "2015-02-06 14:12:10.257034", "rc": 126, "start": "2015-02-06 14:12:10.252296", "warnings": []}
stderr: /bin/sh: /var/app/check-feed-adapter-folders/check-feed.sh: Permission denied

FATAL: all hosts have already failed -- aborting

有谁能够帮助我?

最佳答案

如果您可以通过 sh /.../check.sh 运行命令并且命令模块中的运行不起作用(权限被拒绝),那么我认为该文件不可执行。

明确解决此调用 /bin/sh /.../check.sh在你的剧本中:

# run check-feed-adapter-folders script. the script tries to create some folders on HDFS.
- command: /bin/sh "{{check_feed_adapter_folders_outputpath}}/check.sh"

或者,您可以检查您的脚本在文件开头是否有 shebang 行( #!/bin/sh )并使其可执行( chmod 755 /.../check.sh )。

关于ansible - 关于ansible,尝试执行脚本时权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28367686/

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