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

`

  • name: Update apt cahce
    apt: update_cache=yes cache_valid_time=3600

  • name: Install NFS Common on FileServer
    apt: name={{ item }} state=present
    with_items:

  • nfs-common

  • name: Create webservers directory
    file:
    path: /nfs/{{ item.value.folder }}
    state: directory
    with_dict:

  • “{{ webservers }}”

  • mount a webserver for each folder
    mount:
    path: /nfs/{{ item.value.folder}}
    src: {{ item.value.mount }}
    fstype: nfs
    state: present
    with_dict:

  • "{{ webservers }}

`

`

  • hosts: fileserver
    become: true
    become_method: sudo

roles:

  • mount

vars:
webservers:
webserver1:
folder: webserver1
mount: ip:/var/www/wordpress
webserver2:
folder: webserver2
mount: ip:/var/www/wordpress

`

The error appears to have been in ‘/home/victors/.ansible/roles/mount/tasks/main.yml’: line 19, column 8, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  • mount a webserver for each folder
    mount:
    ^ here

The problem is with the following:


- mount a webserver for each folder
mount:

You are missing a name: . You instead want:


- name: mount a webserver for each folder
mount: