2017-06-01 156 views
-1

我想從使用Ansible的遠程服務器克隆git存儲庫。這是我正在嘗試:無法在我的本地使用Ansible克隆git存儲庫

--- 
# - name: '<some name>' 
- hosts: localhost 
    #vars: 
    # - destination: /home/atul/Workplace/test-ansible 
    # - http_port: 80 
    # - max_clients: 200 
- gather_facts: true 
- tasks: 
    - git: 
     repo: http://<my git url>/test/test.git 
     dest: /home/atul/Workplace/test-ansible 
     version: master 

我在我的終端得到這個。

PLAY [localhost] ****************************************************************************************************************************** 

TASK [Gathering Facts] ************************************************************************************************************************ 
ok: [127.0.0.1] 
ERROR! the field 'hosts' is required but was not set 

我不知道我在做錯的地方。

回答

0

我認爲你需要指定主機或與主機清單文件中

嘗試運行這樣的:ansible-playbook <playbook>.yml -i [localhost,]

+0

約1.5年前,這可能是一個有效的建議(雖然不是真的回答這個問題)。 – techraf

0

你應該定義劇中飾演一個字典:

--- 
- hosts: localhost 
    gather_facts: true 
    tasks: 
    - git: 
     repo: http://<my git url>/test/test.git 
     dest: /home/atul/Workplace/test-ansible 
     version: master 

在你的情況下,你有三個缺少參數的遊戲。第一個不做任何事,第二個只包含gather_facts,這就是爲什麼你會得到一個錯誤,hosts字段丟失。