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

1,660 views
Skip to first unread message

Victor Sava

unread,
Jun 28, 2018, 6:09:58 AM6/28/18
to Ansible Project

- 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

Matt Martz

unread,
Jun 28, 2018, 10:24:48 AM6/28/18
to ansible...@googlegroups.com
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:
```

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c0f3ddf9-76e6-4038-8a31-d05b7f04135e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages