I wrote a playbook to count number of host in inventory, can someone look or suggest better way of achieving this task, this play gives error in compling stage itself, however when I check the syntax in
http://codebeautify.org/yaml-validator this shows it is valid.
Please add your comment and suggestions ?
My Playbook
---
- name: Host Entry in Inventory
hosts: "ios_switches"
gather_facts: no
connection: local
task:
- name: Host Count
vars:
num_hosts: "{{ groups['ios_switches'] | length }}"
Error I get after running playbook
ERROR! 'task' is not a valid attribute for a Play
The error appears to have been in '/home/gurmisin/ansible/host_count.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: Host Entry in Inventory
^ here