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