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
39 views

1 answer to this question.

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
• 46,110 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,890 points
1,807 views
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer