Ansible role dependcies/requirements.yml

67 views
Skip to first unread message

smitconsu...@gmail.com

unread,
Aug 22, 2017, 9:09:03 AM8/22/17
to Ansible Project
Hi

How can I use/configure requirements.yml? I have configured roles for all 3 groups , one role for each group. Inside every role/tasks/main.yml I have include file
- include: status check playbook.yml

Master playbook is as below:

---

- hosts: groupA

  roles:

    - main-role/groupa-status-check

 

- hosts: groupB

  roles:

    - main-role/groupb-status-check


- hosts: groupC

  roles:

    - main-role/groupc-status-check

 

Now after status check, I need to run 3 additional playbooks, one by one on all above groups. These playbooks are resided in subversion repository. These playbooks are required to be checked out with latest version. I found requirements.yml could be solution but I could not understand how this will be configured or how can I configure these pre-requites? I am new to ansible. Can someone please help how could I achieve this? Many Thanks


Soniya panwar

unread,
Aug 22, 2017, 10:02:14 AM8/22/17
to Ansible Project
you can add pretask and post task within your master playbook:

---

- hosts: groupA

  pre_tasks:

   -name: <Add your task>

  roles:

    - main-role/groupa-status-check

  post_tasks:

  -name: <Add your task>.

you can also go through this page: "http://docs.ansible.com/ansible/latest/playbooks_roles.html" for more information.

Shez Malik

unread,
Aug 22, 2017, 4:59:43 PM8/22/17
to ansible...@googlegroups.com
Thanks Soniya. 
Actually there are three playbooks which are required to be checked out from subversion and play after every role called in master playbook. Every role has status check play book in it. So if I use post tasks as a method as you said, means after every role there will be post tasks? Lets say in future if there will be 20 roles 20 post tasks. Can we add post tasks(playbooks from subversion) somehow inside roles? Or place post tasks in top level dirctory to be used by all roles somehow?
Thanks.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/LOMYqxh8pr4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b654b59a-e2f1-4200-b450-6dd55fedd221%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Soniya panwar

unread,
Aug 23, 2017, 6:04:30 AM8/23/17
to Ansible Project
>>Can we add post tasks(playbooks from subversion) somehow inside roles? Or place post tasks in top level dirctory to be used by all roles somehow?
Yes, we can do that by defining dependency in main.yml in meta directory.

Example:
#meta/main.yml

Dependencies:
- ansiblr-role

Reply all
Reply to author
Forward
0 new messages