简体   繁体   English

使用Ansible剧本创建AMI失败

[英]Failed Create AMI With Ansible Playbook

I've try to create AMI using ansible-playbook, i've already export aws secret key & access into path and ansible version is 2.0.0. 我尝试使用ansible-playbook创建AMI,我已经将AWS密钥导出并访问到路径,而ansible版本是2.0.0。

- hosts: localhost
    tasks:
    - name: create ami
      ec2_ami:
        region: "ap-southeast-1"
        instance_id: "i-c2xxxx"
        name: "jmicro"
        wait: yes
      register: ami

but when i run command : ansible-playbook create_ami.yml, i get this error : 但是当我运行命令:ansible-playbook create_ami.yml时,出现此错误:

ERROR: Syntax Error while loading YAML script, create_ami.yml

Note: The error may actually appear before this position: line 5, column 1

    ec2_ami:
        region: "ap-southeast-1"

is there something wrong with my yaml script ? 我的Yaml脚本有问题吗? but when i run : 但是当我跑步时:

# ansible localhost -m ec2_ami -a "instance_id=i-c2xxxx region=ap-southeast-1 wait=yes name=jmicro"

it's success !! 成功了!

There are some strange characters in front of tasks . tasks前面有一些奇怪的人物。 Don't know what that is but when I copy your code block and paste it into my editor, then try to remove the whitespaces with Backspace , it actually deletes the characters on the right side of the curser. 不知道那是什么,但是当我复制代码块并将其粘贴到编辑器中,然后尝试使用Backspace删除空格时,实际上删除了光标右侧的字符。

YAML only allows whitespaces for indenting lines. YAML仅允许空格用于缩进行。 I think that is the issue here. 我认为这就是这里的问题。 And tasks needs to be on the same level as hosts . 并且tasks必须与hosts处于同一级别。 Other than that your definition looks OK to me. 除此之外,您的定义对我来说还可以。

- hosts: localhost
  tasks:
    - name: create ami
      ec2_ami:
        region: "ap-southeast-1"
        instance_id: "i-c2xxxx"
        name: "jmicro"
        wait: yes
      register: ami

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM