Ansible playbook errors

I am getting ansible playbook errors while executing the below

ansible-playbook -i hosts --private-key /home/ubuntu/ansible.pem apache.yaml

below is the error… can you please help where I am doing mistake…Also I am pasting my playbook syntax ( yaml)

[WARNING]: Unable to parse /home/ubuntu/hemanthp03/Ansible/apacheserver/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: No JSON object could be decoded

Syntax Error while loading YAML.
mapping values are not allowed in this context

The error appears to be in ‘/home/ubuntu/hemanthp03/Ansible/apacheserver/apache.yaml’: line 4, column 10, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  • name: apc play
    hosts: all
    ^ here

------yaml syntax ---------

  • name: apc play
    hosts: all
    become: yes
    tasks:
    - name: update ubuntu packages and install apache
    apt:
    name: apache2
    update_cache: :yes
    state: present

there seems to be some errors in the YAML format structure. Try using the http://www.yamllint.com/ to test your file for structural errors before executing in Ansible

You can use the YAML file as below and it will work fine:

- hosts: all
  become: true
  tasks:
  - name: "update ubuntu package and install apache"
    apt:
      name: apache2
      state: present
      update_cache: true

Screen Shot 2021-05-18 at 23.49.08