'gcp_compute_disk' is not a valid attribute for a Play

Hi Team,

Trying to spinup windows VM using ansible in GCP. While executing the playbook, getting error as “‘gcp_compute_disk’ is not a valid attribute for a Play”

Here is the code we are using(mentioned is the error part of code):

 name: Create an instance
  hosts: localhost
  gather_facts: no
  connection: local
  vars:
      project: my-project
      auth_kind: serviceaccount
      service_account_file: /home/my_account.json
      zone: "us-east1-b"
      region: "us-east1"

  tasks:
   - name: create a disk
     gcp_compute_disk:
         name: 'network-instance'
         size_gb: 50
         source_image: 'projects/windows-cloud/global/images/windows-server-2016-dc-v20190312'
         zone: "us-east1-b"
         project: "Ansible-automation"
         auth_kind: "serviceaccount"
         service_account_file: "/home/my_account.json"
         scopes:
           - https://www.googleapis.com/auth/compute
         state: present
     register: disk
Error:

Ansible version:

You are missing a dash infront of name

- name: Create an instance

Sorry, I missed mentioning here in the code. But dash is placed infront of name in the playbook.

Hi,

Any update on this please…?

You usually get this error when there are syntax error in the yaml or indentation error.
But since you post with HTML that don't preserve indentation it's impossible to give any more advise.

It you still have problem post in plan text instead an maybe someone is able to help.

Hi,

Please find the code in plain text format.

Hii

Hi,

Also this is the error related to gcp modules.

Your tasks is not indented correctly, indentation in yaml is important to get correct.
Study the examples in documentation to learn the correct indentation.

https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#playbook-language-example