# Run one playbook after another has finished?

**URL:** <https://forum.ansible.com/t/run-one-playbook-after-another-has-finished/30475>\
**Category:** Ansible Project\
**Created:** [June 3, 2019, 10:40am UTC](https://forum.ansible.com/t/run-one-playbook-after-another-has-finished/30475 "2019-06-03T10:40:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [June 3, 2019, 10:40am UTC](https://forum.ansible.com/t/run-one-playbook-after-another-has-finished/30475/1 "2019-06-03T10:40:41Z")

</div>

Hi

I have a play that fetches some custom roles into a directory. These  
roles are then used in a subsequent play. My overarching playbook  
looks like:

- name: Fetch roles  
&nbsp;&nbsp;hosts: all  
&nbsp;&nbsp;connection: local  
&nbsp;&nbsp;tags: always  
&nbsp;&nbsp;run\_once: yes  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- Role fetch logic here...

- name: Deploy stuff  
&nbsp;&nbsp;hosts: all  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;&nbsp;&nbsp;- myrole1  
&nbsp;&nbsp;&nbsp;&nbsp;- myrole2  
&nbsp;&nbsp;&nbsp;&nbsp;- myrole3

This works. But when starting from scratch, i.e. when the first play  
has never run, the directory where it will put the roles is empty.  
This causes the playbook to fail with

ERROR! the role 'myrole1' was not found in....

So all plays/tasks are evaluated and it throws an error because a role  
does not exist yet (which makes sense).

We're already using a wrapper shell script around ansible-playbook to  
ease deployment by feeding it things like vault ID, inventory etc, so  
I'm tempted to just add a extra ansible-play run first that does the  
role fetching.

Is there a way to make this work by running ansible only once?

Thanks

Dick

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [June 3, 2019, 5:29pm UTC](https://forum.ansible.com/t/run-one-playbook-after-another-has-finished/30475/2 "2019-06-03T17:29:32Z")

</div>

Pretty sure it's not possible in one playbook.  
But if you split it in two playbooks you only need one ansible-playbook, so it sort of only once.

ansible-playbook fetch.yml deploy.yml

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [June 3, 2019, 7:37pm UTC](https://forum.ansible.com/t/run-one-playbook-after-another-has-finished/30475/3 "2019-06-03T19:37:40Z")

</div>

Thanks, this will do nicely.
