我有以下ansible劇本:使用從源代碼安裝Python包ansible
- hosts: all
gather_facts: false
sudo: true
tasks:
- name: Pull sources from the repository.
git: repo=https://github.com/mongodb-labs/mongo-connector.git dest=/srv/checkout/mongo-connector
- hosts: all
sudo: true
tasks:
- name: copy local config.json to remote if exists
local_action: stat path="./config.json"
register: file
ignore_errors: True
- name: copy file if it exists
copy: src=./config.json dest=/srv/checkout/mongo-connector/config.json force=yes
when: file.stat.exists
- hosts: all
sudo: true
tasks:
- name: copy local install_mc.sh to remote if exists
local_action: stat path="./install_mc.sh"
register: file
ignore_errors: True
- name: copy installation scripts
copy: src=./install_mc.sh dest=/srv/checkout/mongo-connector/install_mc.sh mode=755
when: file.stat.exists
- name: Execute script
script: /srv/checkout/mongo-connector/install_mc.sh
這裏我拉一個倉庫從GitHub,然後我一個config.json
複製到我克隆Git倉庫的文件夾。之後,我需要運行python setup.py install
安裝該軟件包,然後在同一目錄中運行python setup.py install_service
。
我把這兩個安裝命令放在一個shell文件install_mc.sh
中,並將該文件複製到克隆存儲庫的同一目錄中。
git倉庫克隆在/srv/checkout/mongo-connector/
。
以下是目錄佈局:
[email protected]:/srv/checkout/mongo-connector$ pwd
/srv/checkout/mongo-connector
[email protected]:/srv/checkout/mongo-connector$ ls
CHANGELOG.rst config.json ez_setup.py install_mc.sh LICENSE mongo_connector README.rst scripts setup.cfg setup.py tests
但後來我的install_mc.sh
執行過程中運行使用無業遊民,我得到的跟隨着錯誤ansible腳本:
==> connector: TASK [Execute script] **********************************************************
==> connector: task path: /vagrant/provisioning/mc_playbook.yml:36
==> connector: fatal: [127.0.0.1]: FAILED! => {"changed": true, "failed": true, "rc": 2, "stderr": "chmod: cannot access ‘./setup.py’: No such file or directory\npython: can't open file './setup.py': [Errno 2] No such file or directory\npython: can't open file './setup.py': [Errno 2] No such file or directory\n", "stdout": "", "stdout_lines": []}
==> connector:
==> connector: NO MORE HOSTS LEFT *************************************************************
==> connector: to retry, use: --limit @mc_playbook.retry
==> connector:
==> connector: PLAY RECAP *********************************************************************
==> connector: 127.0.0.1 : ok=10 changed=4 unreachable=0 failed=1
的install_mc.sh
內容是:
#!/usr/bin/env bash
chmod +x ./setup.py
python ./setup.py install
python ./setup.py install_service
我應該如何解決這個問題?