2017-10-17 65 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

感谢您的回应,这工作:) –