2015-02-06 186 views
1

我是newbee with ansible,所以我在嘗試運行自己的playbook時遇到錯誤。關於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-劇本命令的輸出:

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 

這是奇怪的,因爲如果我嘗試手動運行該腳本,它完美作品

[[email protected] 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 

有人能幫助我嗎?

回答

3

如果您可以通過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" 

Alternativly你可以檢查你的腳本是否有在文件(#!/bin/sh)的開始家當線並使其executeable(chmod 755 /.../check.sh)。

+0

謝謝!它可以像chmod + x一樣使腳本可執行 – aironman 2015-02-06 14:57:30

相關問題