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

问题描述 投票:0回答:1

我正在编写我的第一本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
ansible
1个回答
1
投票

ansible中的剧本遵循一些语法和格式。

使用以下:

---
- 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>
© www.soinside.com 2019 - 2024. All rights reserved.