使用Ansible获取AWS实例详细信息

时间:2019-03-22 05:51:16

标签: ansible

我正在编写我的第一本Ansible剧本,以从AWS获取一些实例详细信息,但是我无法正确获取该剧本。我收到此错误:ERROR! playbooks must be a list of plays

下面是我的剧本。

#get vailable instance details
-name: "Create and attach ebs volumes"

tasks:
        ec2_instance_facts:
         region: us-west-2
         filter :
         "tag:role": PrimaryApplicationInstance

1 个答案:

答案 0 :(得分:1)

这本剧本遵循一些语法和格式。

在下面使用:

---
- name: <name of the playbook>
  hosts: <hosts_group>
  tasks:
    - name: <name of the task for reference>
      ec2_instance_facts:
        <module arguments>

ansible遵循yaml格式缩进2个空格。

由于您是新手,因此可以使用以下命令检查剧本的语法。

ansible-playbook --syntax-check <playbook_file_name>.yml -i inventory

-i --> inventory file where hosts and vars can be defined in the format
<var_name> = <var_value>
相关问题