Hey I'm trying to execute a playbook but I get the following error:

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

The error appears to have been in '/etc/ansible/playbooks/hostname.yml': line 3, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

-hosts: all
 tasks:
      -command: hostname
Mar 26 in Ansible by anonymous
9 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey, you have a syntax error as mentioned in the error log. There should be a space between '-' and command and between '-' and hosts.

Replace it with the following:

- hosts: all
  tasks:
       - command: hostname 
answered Mar 26 by Kalgi
• 35,750 points

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 6,480 points
221 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.