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, 2019 in Ansible by anonymous
757 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, 2019 by Kalgi
• 52,360 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
• 7,340 points
6,830 views
0 votes
2 answers
0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
4,103 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP