2017-10-14 1 views
0

첫 플레이 북이 있는데 실패했습니다. 나는 그것이 구문 오류라고 생각하지만 나는 코더가 아니기 때문에 YAML이 실패하는 이유를 모른다. 간격과 관련이 있습니까? 여기간단한 플레이 북에서 YAML 구문 오류가 발생할 수 있습니다.

내가 무엇을 가지고 : 첫째

--- 
- name: Update all packages to the latest version 
    become: true 
    apt: 
     update_cache: yes  
     upgrade: dist 

- name: Remove useless packages from the cache 
    apt: 
     autoclean: yes 

- name: Remove dependencies that are no longer required 
    apt: 
     autoremove: yes 
ERROR! Syntax Error while loading YAML. 


The error appears to have been in '/home/pi/playbooks/update-apt.yml': line 3, column 11, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

- name: Update all packages to the latest version 
    become: true 
     ^here 

답변

1

: 그것은 재생 (hosts 선언을 포함해야 함),하지만 작업이 포함되어 있지 않기 때문에이는 플레이 북이 아니다.

두 번째로 들여 쓰기가 심각하게 손상되었습니다. YAML에서 선언문을 올바르게 정렬하는 것이 중요합니다 (즉, YAML 구문 오류가 아니라 올바르게 정의 된 부적절한 데이터로 인한 Anipal 오류 YAML 파일 작성).

로컬로 실행하려는 경우가 더 많거나 적은 다음과 같아야합니다

--- 
- hosts: localhost 
    connection: local 
    tasks: 
    - name: Update all packages to the latest version 
     become: true 
     apt: 
     update_cache: yes  
     upgrade: dist 
     autoclean: yes 
     autoremove: yes 
관련 문제