2016-01-22 51 views
0

當通過Ansible拉使用Ansible,該template指令的validate一步未能找到%s指定的文件。Ansible通過Ansible拉找不到文件:驗證=「統計%S」`

「沒有這樣的文件」 的錯誤由ansible-pull報道:

TASK [ssh : place ssh config file] ********************************************* 
fatal: [localhost]: FAILED! => { 
    "changed": true, 
    "cmd": "sshd -t -f /home/nhooey/.ansible/tmp/ansible-tmp-1453485441.94-279324955743/source", 
    "failed": true, 
    "msg": "[Errno 2] No such file or directory", 
    "rc": 2 
} 

有問題template指令:

- name: place ssh config file 
    template: 
    src: etc/ssh/sshd_config 
    dest: /etc/ssh/sshd_config 
    owner: root 
    group: root 
    mode: 0644 
    validate: 'sshd -t -f %s' 

這種情況與任何Ansible 1.9.4或2.0.0.2從(Python 2.7' 版s Pip)並且只有在使用Ansible Pull時。在手動檢出存儲庫後,在本地運行ansible-playbook工作正常。

不幸的是,我無法用我創建的示例存儲庫在重要情況下重現此錯誤。

故障重現錯誤與簡單的測試案例:

$ virtualenv .venv && source .venv/bin/activate && pip install ansible 
$ ansible-pull --directory /tmp/ansible-test \ 
    --url https://github.com/nhooey/ansible-pull-template-validate-bug.git playbook.yaml 
Starting Ansible Pull at 2016-01-22 13:14:51 
/Users/nhooey/git/github/nhooey/ansible-pull-template-validate-bug/.venv/bin/ansible-pull \ 
    --directory /tmp/ansible-test \ 
    --url https://github.com/nhooey/ansible-pull-template-validate-bug.git \ 
    playbook.yaml 
localhost | SUCCESS => { 
    "after": "07bb13992910e0efe30d071d5f5a2a2e88251045", 
    "before": "07bb13992910e0efe30d071d5f5a2a2e88251045", 
    "changed": false 
} 
[WARNING]: provided hosts list is empty, only localhost is available 

PLAY *************************************************************************** 

TASK [setup] ******************************************************************* 
ok: [localhost] 

TASK [Delete template file] **************************************************** 
changed: [localhost] 

TASK [Test template validation] ************************************************ 
changed: [localhost] 

PLAY RECAP ********************************************************************* 
localhost     : ok=3 changed=2 unreachable=0 failed=0 

劇本,不會在簡單的測試用例上述失敗:

--- 

- hosts: localhost 

    tasks: 
    - name: Delete template file 
     file: 
     path: /tmp/file 
     state: absent 

    - name: Test template validation 
     template: 
     src: file 
     dest: /tmp/file 
     validate: 'ls %s' 

好像有可能是與有問題在ansible-pull創建並刪除Ansible中的臨時文件時進行計時。

發生了什麼事?

回答

0

它說,它無法找到sshd,因爲它不是在路徑。我傻...