2017-10-13 78 views
0

我一直在嘗試部署我的劇本,但不知道錯誤是什麼。我的劇本看起來是這樣的:無法解析劇本錯誤在劇本中

- name: trying to find sb ami 
    ec2_ami_find: 
     owner: self 
     name: SB 
    register: ami_find 

- name : use custom ami 
    ec2: 
    image: "{{ ami_find.results[0].ami_id }}" 
    instance_type: t2.small 
    key_name: mykey 
    region: us-east-1 
    wait: yes 
    register: ec2 

我收到錯誤持續這樣的:

ERROR! Syntax Error while loading YAML. 


The error appears to have been in '/root/git-work/ansible/sparkbeyond.yml': line 16, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

    register: ami_find 

^here 
There appears to be a tab character at the start of the line. 

YAML does not use tabs for formatting. Tabs should be replaced with spaces. 

For example: 
    - name: update tooling 
     vars: 
     version: 1.2.3 
# ^--- there is a tab there. 

Should be written as: 
    - name: update tooling 
     vars: 
     version: 1.2.3 
# ^--- all spaces here. 

可以有一個人請幫幫我,爲什麼我收到這樣的錯誤。我在ubuntu機器上使用的是2.3版本的可執行版本。

回答

1

您的縮進在第一個遊戲中關閉。在第二次播放中,register不是ec2模塊的參數。

- name: trying to find sb ami 
    ec2_ami_find: 
    owner: self 
    name: SB 
    register: ami_find 

- name: use custom ami 
    ec2: 
    image: "{{ ami_find.results[0].ami_id }}" 
    instance_type: t2.small 
    key_name: mykey 
    region: us-east-1 
    wait: yes 
    register: ec2