Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone provide a minimal working example of ansible role dependencies?

I am trying to use Ansible's dependencies feature but I cannot get it to work. Could someone provide a minimal example of a role that depends on another role that uses the dependencies feature eg:

--- dependencies: - { role: common }

Many thanks.

like image 643
James Avatar asked Oct 01 '22 05:10

James


1 Answers

You should be able to use it if you put the content you specified in your question in this file:

<your-project-home>/roles/webservers/meta/main.yml 

Make sure your common role exists in:

<your-project-home>/roles/common

Make sure your project structure looks like this:

yourplaybook.yml
roles/
   common/
   webservers/

yourplaybook.yml should look something like this:

---
- hosts: all
  roles:
     - webservers

Then you would call your playbook like this:

ansible-playbook -i ./inventory-file yourplaybook.yml
like image 53
Rico Avatar answered Oct 07 '22 06:10

Rico