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

41 views
Skip to first unread message

op...@netexpress.de

unread,
May 3, 2019, 5:38:51 AM5/3/19
to Ansible Project
I have the following playbook:
---
- hosts: debian
  order: sorted
  tasks:
  -name: postfix - set debconf defaults before postfix install
    shell: debconf-set-selections <<< "postfix postfix/mailname string {{ inventory_hostname }}" executable=/bin/bash
    tags: postfix

But i get the error:
ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to have been in '/opt/ansible/playbooks/postfix.yml': line 6, column 12, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    -name: postfix - set debconf defaults before postfix install
      shell: debconf-set-selections <<< "postfix postfix/mailname string {{ inventory_hostname }}" executable=/bin/bash
           ^ 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 }}"

Help, please! What am i doing wrong?

Sebastian Meyer

unread,
May 3, 2019, 5:44:28 AM5/3/19
to ansible...@googlegroups.com, op...@netexpress.de
On 03.05.19 11:38, op...@netexpress.de wrote:
> -name: postfix - set debconf defaults before postfix install

You are missing a space here between the hyphen and name.

Sebastian

--
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

Tony Chia

unread,
May 4, 2019, 10:14:43 AM5/4/19
to Ansible Project
You can check if you have a valid syntax at 

http://www.yamllint.com/

In YAML, sequences must have a dash followed by a space. 
Reply all
Reply to author
Forward
0 new messages