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

StackOverflow https://stackoverflow.com/questions/22617988

  •  20-06-2023
  •  | 
  •  

سؤال

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.

هل كانت مفيدة؟

المحلول

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top