ERROR! 'ec2_ami' is not a valid attribute for a Play

341 views
Skip to first unread message

Sivabalan Nagarajan

unread,
Apr 4, 2017, 2:21:34 PM4/4/17
to Ansible Project
This is my playbook and while running I'm getting the error which is in subject line.

Can someone know what could be the issue?

---
- hosts: localhost
  connection: local
  gather_facts: false

  vars_prompt:
    -
      name: aws_access_key
      prompt: "Enter AWS Access key:"
    -
      name: aws_secret_key
      prompt: "Enter AWS Secreat key:"
    -
      name: instance_id
      prompt: "Which instance you want to take AMI?"
    -
      name: instance_name
      prompt: "Name of the new AMI?"
    -
      name: name_tag
      prompt: "Name tag of the instance:"
    -
      name: environment_tag
      prompt: "Environment tag of the instance:"

- ec2_ami:
    aws_access_key: "{{ aws_access_key }}"
    aws_secret_key: "{{ aws_secret_key }}"
    instance_id: "{{ instance_id }}"
    name: "{{ name }}"
    no_reboot: false
    tags:
      Environment: "{{ environment_tag }}"
      Name: "{{ name_tag }}"
    wait: true
  register: image

Brian Coca

unread,
Apr 4, 2017, 2:52:11 PM4/4/17
to Ansible Project
It needs to be indented inside a 'tasks:' keyword of the play to be
recognized as a task.

The error indicates you are in 'play' context so it is invalid there.

----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages