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
  roles:
    - nginx

Error:

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:

  roles:
    - nginx
      ^ here
Mar 12, 2019 in Ansible by Bob
2,671 views

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: https://github.com/jdauphant/ansible-role-nginx

And use it as described in its README.md

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
15,864 views
0 votes
1 answer
+1 vote
3 answers
0 votes
1 answer
+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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
+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
21,821 views
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