Thanks  it worked.

vars:
    foo: ['vs1','vs2','vs3','vs4']
  tasks:
    - name: counting the array elements
      debug:
         msg: "{{foo|length}}"
 

On Thursday, 19 March 2020 20:53:58 UTC+5:30, mahesh g o wrote:
>
> - hosts: localhost
>   gather_facts: false
>   vars:
>     foo: ['vs1','vs2','vs3','vs4']
>   tasks:
>     - name: counting the array elements
>         yes: "{{foo|length}}"
>
> seeing the below error: not sure what am i missing here:
>
> ERROR! Syntax Error while loading YAML.
>   mapping values are not allowed in this context
>
> The error appears to be in '/root/ansible/playbooks/syst/lab.yml': line 7, 
> column 12, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>     - name: counting the array elements
>         yes: "{{foo}}"|length
>            ^ here
> We could be wrong, but this one looks like it might be an issue with
> missing quotes. Always quote template expression brackets when they
> start a value. For instance:
>
>     with_items:
>       - {{ foo }}
>
> Should be written as:
>
>     with_items:
>       - "{{ foo }}"
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a2c23b00-a8bc-473f-b35f-f05c4cb938e3%40googlegroups.com.

Reply via email to