Run one playbook after another has finished?

22 views
Skip to first unread message

Dick Visser

unread,
Jun 3, 2019, 6:41:08 AM6/3/19
to ansible...@googlegroups.com
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
hosts: all
connection: local
tags: always
run_once: yes
tasks:
- Role fetch logic here...

- name: Deploy stuff
hosts: all
roles:
- myrole1
- myrole2
- 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


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Kai Stian Olstad

unread,
Jun 3, 2019, 1:29:42 PM6/3/19
to ansible...@googlegroups.com
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


--
Kai Stian Olstad

Dick Visser

unread,
Jun 3, 2019, 3:38:04 PM6/3/19
to ansible...@googlegroups.com
Thanks, this will do nicely. 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/45de3c8b-0900-1ba0-42ac-7fdde72f4f10%40olstad.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.
Reply all
Reply to author
Forward
0 new messages