Error while running playbook consisting of roles - Ansible

0 votes

I've created my first ansible role and I'm getting an error.

- hosts: webservers
    - nginx


ERROR! the role 'nginx' was not found in /root/roles:/root:/etc/ansible/roles

The error appears to have been in '/root/server.yml': line 4, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    - nginx
      ^ here
Mar 12, 2019 in Ansible by Bob

1 answer to this question.

0 votes

You get this error because ansible was not able to find nginx role in your file hierarchy. 

If you want to use a role named nginx, ansible will try to load a file nginx/tasks/main.yml in one of your roles folders.

Copy into your nginx role folder this code:

And use it as described in its

answered Mar 12, 2019 by William

Related Questions In Ansible

0 votes
1 answer

Error saying permission denied while running ansible playbook

Hey @Neha, add the following line to ...READ MORE

answered Feb 8, 2019 in Ansible by Amy
0 votes
1 answer
+1 vote
3 answers
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer
+1 vote
2 answers

What is the difference between ansible playbook and roles?

Hi, Roles: Roles containing certain vars_files, tasks, and handlers ...READ MORE

answered Jan 21, 2020 in Ansible by vivek
• 530 points