2017-10-17 62 views
0

一邊跑我ansible劇本我得到這個錯誤以下異常類型:<類的ansible.errors.AnsibleParserError'>

我YAML文件:

--- 
- hosts: ubuntu 
    become: yes 
    remote_user: ansible 
    tasks: 
    - name: update the cache 
    apt: 
     name: update 
     update_cache: yes 
    - name: This will install apache 
    apt: 
    name:apache2 
    state:present 

錯誤: 異常類型: 例外:這個任務'apt'有額外的params,它只允許在下列模塊中使用:command,win_command,shell,win_shell,script,include,include_vars,include_tasks,include_role,import_tasks,import_role,add_host,group_by,set_fact,raw, meta

錯誤似乎在'/home/ansible/playbooks/apache.yml'中:第10行第5列,但可能 位於文件的其他位置,具體取決於確切的語法問題。

+1

如果不正確地格式化你的問題你問的代碼變得幾乎無法讀取。我已經爲你修復了劇本。 – larsks

回答

0

您的YAML語法有錯誤。字典的語法是:

key: value 

請注意:之後的空格。您有:

- name: This will install apache 
    apt: 
    name:apache2 
    state:present 

您需要:

- name: This will install apache 
    apt: 
    name: apache2 
    state: present 
+0

感謝您的迴應,這工作:) –